Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. program Lottogenerator;
  2. const iArray=6;
  3. const lotto=49;
  4. const Tipp=6;
  5. const icounteran=6;
  6. const counter = 1000000;
  7. type iZahlen5 = array[1..icounteran] of integer;
  8. type iZahlen = array[1..iArray] of integer;
  9. type iZahlen2 = array[1..lotto] of integer;
  10. type iZahlen3 = array[1..Tipp] of integer;
  11. type iZahlen4 = array[1..counter] of integer;
  12. var iWert:iZahlen;
  13. var iLotto:iZahlen2;
  14. var iTipp:iZahlen3;
  15. var icounter:iZahlen4;
  16. var counteran:iZahlen5;
  17. var iIndex, tausch, dummy, abbruch, iAnzahl, iZiehungen, iDurch, flag, icounteran: integer;
  18. begin
  19. Randomize;
  20. write('Wie oft wollen Sie ziehen: '); readln(iZiehungen);
  21.  
  22. for iIndex := 1 to Tipp do
  23. begin
  24. write(iIndex,'. Zahl '); readln(iTipp[iIndex]);
  25. end;
  26.  
  27. //Zufallszahlen zugeteilt(keine doppelten Zahlen)
  28. for iDurch:= 1 to iZiehungen do
  29. begin
  30. for iIndex := 1 to iArray do
  31. begin
  32. repeat
  33.  
  34. iWert[iIndex] := Random(49)+1;
  35. abbruch := 0;
  36. for iAnzahl := 1 to iArray do
  37. begin
  38. If iIndex = iAnzahl then
  39. begin
  40. continue;
  41. end;
  42. If iWert[iIndex] = iWert[iAnzahl] then
  43. begin
  44. abbruch := 1;
  45. end;
  46. end;
  47. until(abbruch=0);
  48. iLotto[iWert[iIndex]]:= iLotto[iWert[iIndex]]+1;
  49.  
  50.  
  51. for flag := 1 to Tipp do
  52. begin
  53. if iTipp[flag]=iWert[iIndex] then
  54. begin
  55. icounter[iDurch]:= icounter[iDurch]+1
  56. end;
  57. end;
  58. end;
  59. writeln('Die Lotto Zahlen lauten: ');
  60. writeln;
  61. For iIndex := 1 to iArray do
  62. begin
  63. writeln(iIndex,'. Zahl: ',iWert[iIndex]);
  64. end;
  65. end;
  66.  
  67. //Sortierung der Zufallszahlen
  68. repeat
  69. tausch := 0;
  70. for iIndex := 1 to iArray-1 do
  71. begin
  72. if iWert[iIndex]>iWert[iIndex+1] then
  73. begin
  74. dummy := iWert[iIndex];
  75. iWert[iIndex] := iWert[iIndex+1];
  76. iWert[iIndex+1] := dummy;
  77. tausch :=1;
  78. end;
  79. end;
  80. until(tausch=0);
  81. readln;
  82. //Ausgabe der sortierten Zahlen
  83. readln;
  84. for iIndex:= 1 to Lotto do
  85. begin
  86. writeln(iIndex,'. Stelle ',iLotto[iIndex]);
  87. end;
  88.  
  89. for iIndex:= 1 to Tipp do
  90. begin
  91. writeln(iTipp[iIndex]);
  92. end;
  93.  
  94. for iIndex:= 1 to iZiehungen do
  95. begin
  96.  
  97. if icounter[iIndex]> 2 then
  98.  
  99. begin
  100. icounteran[icounter[iIndex]]:= icounteran[icounter[iIndex]]+1;
  101. writeln(iIndex,'. Ziehung: ',icounter[iIndex],' Richtige');
  102. end;
  103.  
  104. for iIndex:= 3 to ianzahl do
  105. begin
  106.  
  107. writeln(iIndex,'. Richtige: ',icounteran[iIndex]);
  108. end;
  109.  
  110. end;
  111. readln;
  112. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement