Witam.
Mam taki problem, mam napisać program który będzie sortował babelkowo, problem w tym, że program ten napisałem i normalnie mi działał, ale prof. chciał żeby ten program był z użyciem function. Próbowałem rzeźbić ale kiepsko mi to idzie. Poniżej kod programu. I niby coś tam działa ale nie sortuje mi liczb, tylko jakieś głupoty wyświetla. Plis o pomoc
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
z: Array[1..100] of double;
n:Integer;
i: integer;
implementation
{$R *.dfm}
function sortb(var A: array of double): double;
var
t: Boolean;
i: integer;
c: double;
begin
repeat
t:=true; i:=n;
repeat
i:=i-1;
if z[i+1]< z[i] then
begin //zamniana elementów jeżeli większy poprzedza mniejszy
c:=z[i];
z[i]:=z[i+1];
z[i+1]:=c;
t:=false;
end;
until i=1;
until t=true;
for i:=1 to n do
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s: integer;
begin
n:=StrToInt(Edit1.text);//ilosc liczb do posortowania z edit1 //liczba elementów do sorotwania
Button1.Enabled:=true; //wlaczenie przycisku sortuj
randomize; //mieszanie liczb
for s:=1 to n do
begin
z[s]:=Random(200); //zakres nieposorotwanych od 0 do 200
StringGrid1.Cells[0,s]:=floatToStr(z[s]); //dodawanie elentów do listy nieposortowane
end;
StringGrid1.Cells[1,i]:=FloatToStr(z[i]);
end;
end.