Delphi Lotto-Zahlen

fdbfgh

Cadet 4th Year
Registriert
Nov. 2006
Beiträge
115
Hallo Ihr!

Ich habe jetzt was programmiert, was vom Quelltext eigentlich her richtig sein muss, ichaber trotzdem iwie immer in eine Endlosschleife rutsche!

var
Form1: TForm1;
Lottozahl : ARRAY [1..7] of Integer;
Tippzahl : ARRAY [1..6] of Integer;
Richtige : ARRAY [1..6] of Integer;

implementation

{$R *.DFM}

procedure TForm1.BuZiehenClick(Sender: TObject);
var
i,j,z : Integer;
gefunden : Boolean;
begin
i := 0;

repeat
z := random(49)+1;
gefunden := false;
i := i+1;
for j:= 1 to i do
begin
if z=Lottozahl[j] then
begin
gefunden := true;
i := i-1;
end;
if (gefunden = false) then Lottozahl:=z;
end;
until i=8;

EdZahl1.Text := IntToStr(Lottozahl[1]); // Ausgabe in die Edit-Felder
EdZahl2.Text := IntToStr(Lottozahl[2]);
EdZahl3.Text := IntToStr(Lottozahl[3]);
EdZahl4.Text := IntToStr(Lottozahl[4]);
EdZahl5.Text := IntToStr(Lottozahl[5]);
EdZahl6.Text := IntToStr(Lottozahl[6]);
EdZusatz.Text := IntToStr(Lottozahl[7]);
 
Hm ich hab jetzt zwar kein Delphi zum Nachprüfen da, aber hast du den Zufallsgenerator überhaupt initialisiert? So wie der Quelltext aussieht nämlich nicht.
 
Also rein vom Bauchgefühl her...
Code:
repeat
z := random(49)+1;
gefunden := false;
i := i+1;
for j:= 1 to i do
begin
if z=Lottozahl[j] then
begin
gefunden := true;
i := i-1;
end
else
begin 
Lottozahl[i]:=z;
end;
[B]until i=7[/B]
 
Zurück
Oben