1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57:
| var Form1: TForm1; z:integer; zahl:array[1..5] of integer; implementation
{$R *.dfm}
procedure TForm1.StringGrid1Click(Sender: TObject); var i:integer; begin randomize; z:=1; stringgrid1.Cells[1,0]:='Zahl 1'; stringgrid1.Cells[2,0]:='Zahl 2'; stringgrid1.Cells[3,0]:='Zahl 3'; stringgrid1.Cells[4,0]:='Zahl 4'; stringgrid1.Cells[5,0]:='Zahl 5';
for i:=1 to 5 do begin zahl[i]:=random(100)+1; stringgrid1.Cells[0,1]:='Zufall'; stringgrid1.Cells[i,1]:=inttostr(zahl[i]); end; end;
procedure TForm1.Button1Click(Sender: TObject); var k,i,j,hilf:integer; begin for i:=1 to 4 do begin for j:=i+1 to 5 do if zahl[j]<zahl[i] then begin hilf:=zahl[i]; zahl[i]:=zahl[j]; zahl[j]:=hilf; end;
z:=z+1; for k:=1 to 5 do begin stringgrid1.cells[0,z]:=inttostr(i)+'x sort'; stringgrid1.cells[k,z]:=inttostr(zahl[k]); end; end; end;
procedure TForm1.Button2Click(Sender: TObject); begin close; end;
end. |
das ist mein kompletter quelltext für das bubblesort sortierverfahren....
er gibt jeden einzelnen schritt in einer zeile von einem stringgrid an..soll er ja auch..
aber
ich brauche dafür einem Quelltext für mergesort und komm damit gar nicht klar..er soll wie beim obrigen jeden einzeilnen schritt anzeigen den er durchführt...
ich bedanke mich für eure hilfe...!
Moderiert von
Narses: Delphi-Tags hinzugefügt