unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ListBox1: TListBox;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
Type TFeld =
Array [1..100]
of Integer;
var
Form1: TForm1;
x: Integer;
Feld: TFeld;
implementation
{$R *.dfm}
procedure Beenden();
begin
Application.Terminate;
end;
procedure Generieren(
var Feld: TFeld; x: Integer);
var
i: Integer;
begin
for i := 1
to x
do
begin
Feld[i] := Random(x) + 1;
Form1.ListBox1.Items.Add(IntToStr(Feld[i]));
end;
end;
procedure Ausgabe(x: Integer);
var
i, j: Integer;
begin
for i := 1
to x
do
Form1.ListBox1.Items.Add(IntToStr(Feld[j]));
end;
procedure Tauschen(
var Feld: TFeld);
var
i, j, Temp: Integer;
begin
if (Feld[i] > Feld[j])
then
begin
Temp := Feld[i];
Feld[i] := Feld[j];
Feld[j] := Temp;
end;
Ausgabe(StrToInt(Form1.Edit1.Text));
end;
procedure Sortieren(
var Feld: TFeld; x: Integer);
var
i, j: Integer;
begin
for i := 1
to x - 1
do
for j := i + 1
to x
do
Tauschen(Feld);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Beenden();
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ListBox1.Clear;
Generieren(Feld, StrToInt(Form1.Edit1.Text));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Ausgabe(StrToInt(Form1.Edit1.Text));
end;
end.