Einzelnen Beitrag anzeigen

Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 

Re: Doppelte Zahlen beim Lotto Generator

  Alt 31. Mär 2006, 15:13
Wie soll das denn gehen? if zahl[1]=zahl[2] or zahl[3]...

Ich schlage vor du siehst dir nochmal ein paar Anfänger Tutorials an.

Delphi-Quellcode:
procedure GenerateLottoNumbers;
var isdouble: Boolean;
  I, J: Integer;
  zahl: array[1..6] of Integer;
begin;
randomize;
for I:=1 to 6 do
repeat
zahl[I]:=Random(49)+1;
for J:=1 to 6 do
begin
isdouble:=False;
if I<>J then isdouble:=isdouble or (zahl[I]=zahl[J]);
end;
until not isdouble;
for I:=1 to 6 do (findcomponent('Label'+inttostr(I))as TLabel).caption:=
   inttostr(zahl[I]);
end;
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat