unit a_scheiss;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
za:
array [1 .. 20]
of integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,x,y: integer;
begin
memo1.Clear; memo2.Clear;
for I := 1
to 20
do za[i] := i;
for I := 1
to 20
do
begin
x := random(20-i)+1;
y := za[i];
za[i] := za[x];
za[x] := y;
end;
for i := 1
to 20
do
memo1.Lines.Add(inttostr(za[i]));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,m,x: integer;
begin
for I := 1
to 20
do
begin
x := i;
for j := i+1
to 20
do
if za[x] > za[j]
then
x := j;
begin
m := za[x];
za[x] := za[i];
za[i] := m;
end;
memo2.Lines.Add(inttostr(za[i]));
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;
end.