unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Edit2: TEdit; OpenDialog1: TOpenDialog; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var a: array of Real; i,j,n,k,p: integer; vstr, outs: String; cstr: String; c: real; F1: TextFile; begin if (StrToInt(Edit1.Text) <> 0) then begin if OpenDialog1.Execute then AssignFile(F1, OpenDialog1.Filename); Reset(F1); k:=0; while not Eof(F1) do begin Readln(F1, cstr); a[k]:=StrToFloat(cstr); k:=k+1; end; CloseFile(F1); end else begin SetLength(a,StrToInt(Edit1.Text)); vstr := Edit2.Text; k:=0; for i := 1 to Length(vstr) do begin p:= Pos(' ',vstr); if (p<>0) then begin cstr:=copy(vstr,0,p); delete(vstr,1,p); if (cstr <> ' ') then begin a[k]:=StrToFloat(cstr); k:=k+1; end; end; end; end; n := StrToInt(Edit1.Text)+1; for i:=n-1 downto 1 do for j:=0 to i-2 do { prebublávanie úseku 1..i } if a[j]>a[j+1] then begin c:=a[j]; a[j]:=a[j+1]; a[j+1]:=c { výmena, lebo v menšom indexe väčší prvok } end; outs := ''; for i := 0 to High(a) do begin outs := outs + ','+ FloatToStr(a[i]); end; ShowMessage(outs); end; end.