unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
f:
array [1..2000]
of integer;
// beliebige zahl bis zu 4500
z:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
b:
array [1..2000]
of integer;
ende,maxind,i,hilfs: integer;
// natürlich die namen auch beliebig
begin
memo2.clear;
for i:= 1
to z
do
b[i]:= f[i];
ende:=z;
repeat
maxind:=1;
for i:= 2
to ende
do
if b[i]>b[maxind]
then maxind := i;
hilfs:= b[maxind]; b[maxind] := b[ende];b[ende]:= hilfs;
dec(ende)
until ende =1;
for i:=1
to z
do
memo2.lines.add (inttostr(b[i]));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
memo1.clear; memo2.clear;
randomize;
z:= strtoint (edit1.Text);
for i:= 1
to z
do
begin
f[i] := random (100000);
memo1.lines.Add(inttostr(f[i]));
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.clear;
memo2.Clear;
edit1.clear;
end;
end.