我在做一个结账监控软件:
发货表 fhb 字段: 发货量, 价格,金额
                  10      2   20
                  15      3   45
                  20      4   80
  回款表 hkb    字段:   回货
                        30
                        40
  卖方要求买方,每发货量15量时要结一次账 卖方先3元定金
我想得到一个算法, 每发货发15时 买方是否结过账  谢谢

解决方案 »

  1.   

    把一个整数变成二进制字符串 function IntToBinaryStr(TheVal: LongInt): string;
    var
    counter: LongInt;
    begin
      {This part is here because we remove leading zeros.  
    means that a zero value would return an empty string.}
      if TheVal = 0 then begin
        result := '0';
        exit;
      end;
      result := '';
      counter := $80000000;
      {Suppress leading zeros}
      while  ((counter and TheVal) = 0) do begin
        counter := counter shr 1;
        if (counter = 0) then break; {We found our first "1".}
      end;
      while counter > 0 do begin
        if (counter and TheVal) = 0 then result := result + '0'
        else  result := result + '1';
        counter := counter shr 1;
      end;
    end;// Binary to Integer
    function BinToInt(Value: string): Integer;
    var
    i, iValueSize: Integer;
    begin
      Result := 0;
      iValueSize := Length(Value);
      for i := iValueSize downto 1 do
      if Value[i] = '1' then Result := Result + (1 shl (iValueSize - i));
    end;// Integer to Binary
    function IntToBin(Value: Longint; Digits: Integer): string;
    var
    i: Integer;
    begin
      Result := '';
      for i := Digits downto 0 do
      if Value and (1 shl i) <> 0 then
      Result := Result + '1'
      else
      Result := Result + '0';
    end;