{...}
procedure aktualisieren;
var j: integer;
begin
for j := 0
to 9
do begin
case j
of
0: form1.edit1.text := inttostr(ss_liste[j]);
1: form1.edit2.text := inttostr(ss_liste[j]);
2: form1.edit3.text := inttostr(ss_liste[j]);
3: form1.edit4.text := inttostr(ss_liste[j]);
4: form1.edit5.text := inttostr(ss_liste[j]);
5: form1.edit6.text := inttostr(ss_liste[j]);
6: form1.edit7.text := inttostr(ss_liste[j]);
7: form1.edit8.text := inttostr(ss_liste[j]);
8: form1.edit9.text := inttostr(ss_liste[j]);
9: form1.edit10.text := inttostr(ss_liste[j]);
end;
// von CASE
end;
// von FOR
end;
procedure markiere (farbe:tcolor;x:integer);
begin
case x
of
0: form1.edit1.color := farbe;
1: form1.edit2.color := farbe;
2: form1.edit3.color := farbe;
3: form1.edit4.color := farbe;
4: form1.edit5.color := farbe;
5: form1.edit6.color := farbe;
6: form1.edit7.color := farbe;
7: form1.edit8.color := farbe;
8: form1.edit9.color :=farbe;
9: form1.edit10.color := farbe;
end;
// von CASE
end;
procedure demarkiere(v:integer);
begin
case v
of
0: form1.edit1.color := clWindow;
1: form1.edit2.color := clWindow;
2: form1.edit3.color := clWindow;
3: form1.edit4.color := clWindow;
4: form1.edit5.color := clWindow;
5: form1.edit6.color := clWindow;
6: form1.edit7.color := clWindow;
7: form1.edit8.color := clWindow;
8: form1.edit9.color := clWindow;
9: form1.edit10.color := clWindow;
end;
// von CASE
end;
procedure markieren_pivot (z:integer);
begin
case z
of
0: form1.image1.visible := true;
1: form1.image2.visible := true;
2: form1.image3.visible := true;
3: form1.image4.visible := true;
4: form1.image5.visible := true;
5: form1.image6.visible := true;
6: form1.image7.visible := true;
7: form1.image8.visible := true;
8: form1.image9.visible := true;
9: form1.image10.visible := true;
end;
// von CASE
end;
procedure demarkiere_pivot (z:integer);
begin
case z
of
0: form1.image1.visible := false;
1: form1.image2.visible := false;
2: form1.image3.visible := false;
3: form1.image4.visible := false;
4: form1.image5.visible := false;
5: form1.image6.visible := false;
6: form1.image7.visible := false;
7: form1.image8.visible := false;
8: form1.image9.visible := false;
9: form1.image10.visible := false;
end;
// von CASE
end;
procedure Quicksort(
var a:
array of integer; anfang, ende:integer);
var i, l_pos, r_pos, pivot, temp, pivot_feld: integer;
begin
pivot_feld := (anfang+ende)
div 2;
demarkiere_pivot(pivot_feld);
pivot := a[pivot_feld];
markieren_pivot(pivot_feld);
l_pos := anfang;
r_pos := ende;
repeat
while a[l_pos] < pivot
do inc(l_pos);
while a[r_pos] > pivot
do dec(r_pos);
if l_pos < r_pos
then begin
markiere(clRed, l_pos);
markiere(clRed, r_pos);
sleep(1000);
temp := a[l_pos];
a[l_pos] := a[r_pos];
a[r_pos] := temp;
aktualisieren;
markiere(clGreen, l_pos);
markiere(clGreen, r_pos);
sleep(500);
for i := 0
to 9
do demarkiere(i);
inc(l_pos);
dec(r_pos);
end;
until (l_pos > r_pos) ;
if (anfang < r_pos)
then quicksort(a, anfang, r_pos);
if (l_pos < ende)
then quicksort(a, l_pos, ende);
end;