unit USelect;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
Zufallszahl: integer;
A: array [1..6] of integer;
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button2Click(Sender: TObject);
const Zufallsbereich=100;
begin
Memo1.Lines[0]:=IntToStr(Random(Zufallsbereich)+1);
Memo1.Lines[1]:=IntToStr(Random(Zufallsbereich)+1);
Memo1.Lines[2]:=IntToStr(Random(Zufallsbereich)+1);
Memo1.Lines[3]:=IntToStr(Random(Zufallsbereich)+1);
Memo1.Lines[4]:=IntToStr(Random(Zufallsbereich)+1);
Memo1.Lines[5]:=IntToStr(Random(Zufallsbereich)+1);
end;
procedure TForm1.Button3Click(Sender: TObject);
var i,j,m,x:integer;
const n=5;
begin
for i:=0 to 5 do
begin
x:=i;
for j:=i+1 to n do
if A[x] > A[j] then
x:=j;
begin
m:=A[x];
A[x]:=A[i];
A[i]:=m;
memo2.lines.Add(inttostr(A[i]));
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;
end.