Autor Beitrag
hoehlenpain
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Fr 29.10.10 17:27 
hallo, hab ein programm geschrieben ,welches 7 zahlen generiert und diese dann geordnet (von kleinsten zu größten) ausgibt... (als lottozahlen^^)
nun mein problem... manchmal sind zahlen doppel ---> darauf die frage (nach stündigen rumprobieren) was muss in der markierten schleife rein damit er mir eine neue zahl gibt falls die gezogene schon vorhanden ist >_<?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
var
zahl:array [1..7of integer;
i,j,hilfe:integer;

begin
randomize;
writeln('Lottozahlen: ');
writeln('__________________');
  for i:=1 to 7 do
    begin 
      zahl[i]:=1+random(49);     <--- ich weis das hier eine weitere schleife       
    end;                              reinkommt... nur hat das bis jetzt
  for i:= 1 to 5 do                       noch nicht geklappt >_<
    for j:=i+1 to 6 do
        if zahl[i]>zahl[j] then
            begin
              hilfe:=zahl[i];
              zahl[i]:=zahl[j];
              zahl[j]:=hilfe;
            end;

for j:=1 to 6 do
  begin
    writeln('Zahl',j,': ',zahl[j]);
  end;
writeln('Zusatztzahl: ',zahl[7]);
readln;

end.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 29.10.10 17:31 
Hallo,

du bist nicht der Erste der das fragt: Suche in: Delphi-Forum LOTTOZAHLEN

Grüße,
Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."