622,132,35,403,303,312,235,119,642,858,329,33,154,49,43,561,842,203,915,567,905,609,161,317,574,688,819,310,209,88,909,211,719,503,149,268,868,592,230,98,984,871,518,636,343,694,846,793,112,755,45,849,524,638,326,764,836,364,202,152,850,778,698,78,409,807,472,541,923,139,983,34,190,116,39,814,48,656,507,555,890,556,979,1000,281,272,118,60,751,122,261,274,75,52,204,380,880,800,527,155,685,198,514,258,292,331,876,682,477,777,232,359,802,438,944,99,859,709,841,577,63,603,539,782,351,355,349,607,967,68,625,50,87,563,239,95,336,657,710,998,265,86,282,129,320,73,749,441,989,17,708,23,992,36,67,616,602,437,307,648,354,585,51,318,502,644,739,540
将以上数组由大到小进行排序,并输出最大值与最小值
procedure TForm1.SpeedButton1Click(Sender: TObject); Var i,cID,MaxID,MinID:Integer; cText:String; bNext:Boolean; cStr:Array of integer; cStrList:TStringList; begin cText:=''; Memo2.Clear; cStrList:=TStringList.Create; for i := 0 to Memo1.Lines.Count-1 do cText:=cText+Trim(Memo1.Lines[i]); bNext:=True; while bNext do begin cStrList.Add(Copy(cText,1,Pos(',',cText)-1)); cText:=Copy(cText,Pos(',',cText)+1,Length(cText)); if cText=',' then Break; bNext:=pos(',',cText)>0; end; // Memo2.Lines:=cStrList; exit; SetLength(cStr,cStrList.Count); for I := 0 to cStrList.Count-1 do cStr[i]:=STRTOINT(cSTrList[i]); Tarray.Sort<Integer>(cSTR); for I := Low(cSTR) to High(cSTR) do Memo2.Lines.Add(INTTOSTR(cSTR[i])); Edit1.Text:=INTTOSTR(cSTR[high(cSTR)]); Edit2.Text:=INTTOSTR(cSTR[0]); end;