unit Unit1weilist;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
zehl: TEdit;
hinzu: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
rechner: TButton;
hinweg: TButton;
ergebnis: TEdit;
schluss: TButton;
procedure hinzuClick(Sender: TObject);
procedure hinwegClick(Sender: TObject);
procedure schlussClick(Sender: TObject);
procedure rechnerClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
n,t:integer;
zahl:
array[0..100]
of integer;
implementation
{$R *.dfm}
procedure TForm1.hinzuClick(Sender: TObject);
begin
ListBox1.Items.Add(zehl.Text);
end;
procedure quicksort (l,r:Integer);
var i,j,mitte,merke:integer;
begin
i:=l;
j:=r;
mitte:=zahl[(l+r)
div 2];
repeat
while zahl[i]< mitte
do Inc(i);
while mitte<zahl[j]
do Dec(j);
if i<=j
then
begin
merke:=zahl[i];
zahl[i]:=zahl[j];
zahl[j]:=merke;
inc(i);
dec(j);
end;
until i>j;
if l<j
then Quicksort(l,j);
if i<r
then Quicksort(i,r);
end;
procedure delay(msec:longint);
var
start,stop:longint;
begin
start := gettickcount;
repeat
stop := gettickcount;
application.processmessages;
until (stop - start ) >= msec;
end;
procedure TForm1.hinwegClick(Sender: TObject);
begin
ListBox1.Items.Clear;
ListBox2.Items.Clear;
end;
procedure TForm1.schlussClick(Sender: TObject);
begin
close;
end;
procedure TForm1.rechnerClick(Sender: TObject);
var a,c:integer;
begin
t:=ListBox1.ItemIndex;
t:=t-1;
for a:=0
to t
do
zahl[a]:=strtoint(ListBox1.Items[a]);
quicksort(0,n);
for c:=1
to t
do
begin
ergebnis.Text:=inttostr(zahl[c]);
ListBox1.Items.Add(ergebnis.Text);
end;
end;
end.