unit sazka;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button2: TButton;
Timer1: TTimer;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure losuj();
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,i: integer;
jeneni,stop: boolean;
b: array [0..7] of integer;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
if stop=true then stop:=false else stop:=true;
if i=8 then i:=0;
if i=0 then Form1.Label1.Caption:='';
jeneni:=false;
losuj();
if i=0 then Form1.Label1.Caption:=IntToStr(b[i]) else
Form1.Label1.Caption:=Form1.Label1.Caption+ ', ' +IntToStr(b[i]);
i:=i+1;
end;
procedure TForm1.losuj();
begin
//while stop=false do begin
while jeneni=false do begin
randomize;
a:=random(79);
a:=a+1;
if ((a<>b[0]) and (a<>b[1])
and (a<>b[2]) and (a<>b[3])
and (a<>b[4]) and (a<>b[5])
and (a<>b[6]) and (a<>b[7])) then
begin
jeneni:=true;
b[i]:=a;
end
else jeneni:= false;
end;
// end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var j: integer;
begin
Form1.Button2.Visible:= true;
i:=0;
jeneni:=false; stop:=false;
for j:=0 to 7 do b[j]:=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
while jeneni=false do begin
randomize;
a:=random(79);
a:=a+1;
if ((a<>b[0]) and (a<>b[1])
and (a<>b[2]) and (a<>b[3])
and (a<>b[4]) and (a<>b[5])
and (a<>b[6]) and (a<>b[7])) then
begin
jeneni:=true;
b[i]:=a;
end
else jeneni:= false;
end;
Form1.Label1.Caption:=IntToStr(b[i]);
end;
end.