Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Quicksort (Ausgabe) (https://www.delphipraxis.net/17780-quicksort-ausgabe.html)

Markus K. 9. Mär 2004 20:27

Re: Quicksort (Ausgabe)
 
...ich hab ma schnell was geschrieben, must du nur noch an deine Ausgabe anpassen.

Delphi-Quellcode:
procedure TForm1.QuickSort(links,rechts:integer);
var i,j,h1,h2: integer;
begin
  i:=links;
  j:=rechts;
  h1:=sort[(i+j) div 2];
  repeat
    while sort[i] < h1 do inc(i);
    while sort[j] > h1 do dec(j);
    if i<=j then
    begin
      h2:=sort[i];
      sort[i]:= sort[j];
      sort[j]:= h2;
      SGsortiert.Cells[i-1,1]:=inttostr(Sort[i]);
      SGsortiert.Cells[j-1,1]:=inttostr(Sort[j]);
      inc(i);
      dec(j);
    end;
  until i>j;
  if links<j then Quicksort(links,j);
  if i<rechts then Quicksort(i,rechts);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
     ZahlenEinlesen;
     QuickSort(1,20);
end;
Tschüß Markus


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:07 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz