我寫了一個, 整數沒問題, 但在小數的時候就不一定能列出來! 如 A: (0.278,0.3058,0.3753,0.3892,0.3475,0.3614.......) 已知, 0.278+0.3058=0.5838 b:=0.5838 但列不出來! 幫看看問題在那 !var Str:String; ResultList:TStringList; Xouble; Y,I,z:Integer; bCnt:boolean;begin ResultList := TStringList.Create; try randomize; ResultList.Delimiter := ','; ResultList.DelimitedText := edit1.Text; bCnt := true; while bCnt do begin X := 0.0000; Str := ''; for I:= 0 to ResultList.Count-1 do begin Y := random(10); if Y >5 then begin X := X + StrToFloat(ResultList.Strings); Str := Str + ',' + ResultList.Strings; end; end; if X = StrToFloat(edit2.Text) then begin IF MEMO1.Lines.Count=0 THEN MEMO1.Lines.Add(Str+#13); FOR I:=0 TO MEMO1.Lines.Count-1 DO BEGIN IF Str=MEMO1.Lines.Strings THEN BEGIN Button1.Tag:=0; Break; END; Button1.Tag:=100 END; IF Button1.Tag=100 THEN MEMO1.Lines.Add(Str+#13); end; z:=z+1; if (z > 100000) THEN bCnt:= false; end;finally ResultList.Free;end;end;