Advertisement
facebamm

Lotto 6 aus 49

Oct 20th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.26 KB | None | 0 0
  1. program Lotto_6_aus_49;
  2.  
  3. Uses crt,sysutils;
  4.  
  5. type listtyp = set of byte;
  6.  
  7. function IsInList(i : byte; condision : boolean) : boolean;
  8. begin
  9.    if (condision) then begin
  10.             if(i < 10) then begin
  11.                 Write('  ',i);
  12.             end else begin
  13.                 Write(' ',i);
  14.             end;
  15.             IsInList:= true;
  16.             Exit;
  17.    end;
  18.    IsInList:=false;
  19. end;
  20.  
  21. procedure PrintList(list : listtyp);
  22. var i : byte;
  23. begin
  24.      for i := 0 to 49 do begin
  25.          IsInList(i, i in list);
  26.      end;
  27. end;
  28.  
  29. procedure PrintNumberc(txt : string; list : listtyp; superzahl : byte);
  30. begin
  31.      Write(txt);
  32.      PrintList(list);
  33.      Write('        Superzahl: ',superzahl);
  34. end;
  35.  
  36. procedure GameLoop();
  37. Var Player, Ziehung                     : listtyp;
  38.     Sp_Zahl, Sl_zahl, zahl, i, counter  : byte;
  39.     S_exist, fzahl                      : Boolean;
  40. begin
  41.   Player:=[];
  42.   Ziehung:=[];
  43.   for i := 1 to 6 do begin
  44.       repeat
  45.             try
  46.             Write(i,'/6. Zahl:'); ReadLn(Zahl);
  47.             fzahl := not (zahl in Player) and ((0 < Zahl) and (Zahl < 50));
  48.             if (not fzahl) then
  49.                raise Exception.Create('error');
  50.             except
  51.                 WriteLn('Sie haben einen eingabe Fehler gemacht!!');
  52.             end;
  53.       until(fzahl);
  54.       Player := Player + [Zahl];
  55.   end;
  56.   ClrScr;
  57.   Sp_Zahl:= Random(10);
  58.  
  59.   for i := 0 to 5 do begin
  60.       repeat
  61.             Zahl := Random(49) + 1;
  62.       until not (Zahl in Ziehung);
  63.       Ziehung := Ziehung + [Zahl];
  64.   end;
  65.   //lotto zahlen
  66.   WriteLn('======Lotto======');
  67.   Writeln;
  68.   PrintNumberc('Spieler Zahlen   : ', Player, Sp_Zahl);
  69.   WriteLn;
  70.   PrintNumberc('Lotto Zahlen     : ', Ziehung, Sl_zahl);
  71.   WriteLn;
  72.   Write('Gemeinsame Zahlen: ');
  73.   for i := 0 to 49 do begin
  74.       if(IsInList(i,(i in Player) and (i in Ziehung))) then counter := counter +1;
  75.   end;
  76.  
  77.   S_exist:= (Sp_Zahl = Sl_zahl);
  78.   WriteLn;
  79.   WriteLn('Superzahl        :   ',S_exist);
  80. end;
  81.  
  82. var input : char;
  83. begin
  84.   Randomize;
  85.   repeat
  86.         GameLoop();
  87.         WriteLn;
  88.         repeat
  89.              Write('Wollen Sie nochmal Spielen? [Y]');
  90.              input := ReadKey;
  91.         until (input in ['Y','N','y','n']);
  92.   until not (input in ['y','Y']);
  93. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement