Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace lotto
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int userinput = 0;
  14. int[] userszamok = new int[5];
  15. int[] sorsoltszamok = new int[5];
  16. int sorsolt = 0;
  17. int talalatok = 0;
  18. bool egyenlo = false;
  19. Random rnd = new Random();
  20.  
  21. for (int i = 0; i < userszamok.Length; i++)
  22. {
  23. Console.WriteLine("Kérem az {0}. számot", i + 1);
  24. userinput = int.Parse(Console.ReadLine());
  25. for (int j = 0; j < userszamok.Length; j++)
  26. {
  27. if (userszamok[j] == userinput)
  28. {
  29. Console.WriteLine("ez már volt");
  30. i--;
  31. break;
  32. }
  33.  
  34. }
  35. userszamok[i] = userinput;
  36. }
  37.  
  38. for (int k = 0; k < sorsoltszamok.Length; k++)
  39. {
  40.  
  41. sorsolt = rnd.Next(1, 20);
  42. for (int l = 0; l < sorsoltszamok.Length; l++)
  43. {
  44. egyenlo = false;
  45. if (sorsoltszamok[l] == sorsolt)
  46. {
  47. egyenlo = true;
  48. k--;
  49. break;
  50. }
  51.  
  52. }
  53. if (egyenlo == false)
  54. {
  55. sorsoltszamok[k] = sorsolt;
  56. Console.WriteLine("A(z) {0}. nyerőszám: {1}", k + 1, sorsolt);
  57. }
  58.  
  59. }
  60.  
  61. for (int m = 0; m < userszamok.Length; m++)
  62. {
  63. for (int n = 0; n < sorsoltszamok.Length; n++)
  64. {
  65. if (userszamok[m] == sorsoltszamok[n])
  66. {
  67. talalatok++;
  68. }
  69.  
  70. }
  71.  
  72. }
  73. Console.WriteLine("\n\nA találataid száma: "+ talalatok);
  74.  
  75. int tmp;
  76. int a = sorsoltszamok.Length;
  77. for (int o = a-1; o > 0; o--)
  78. {
  79. for (int p = 0; p < o; p++)
  80. {
  81. if (sorsoltszamok[p] > sorsoltszamok[p+1])
  82. {
  83. tmp = sorsoltszamok[p];
  84. sorsoltszamok[p] = sorsoltszamok[p + 1];
  85. sorsoltszamok[p + 1] = tmp;
  86.  
  87. }
  88.  
  89. }
  90.  
  91. }
  92. Console.WriteLine("\n\nA nyerőszámok növekvő sorban:");
  93. for (int q = 0; q < sorsoltszamok.Length; q++)
  94. {
  95. Console.Write(sorsoltszamok[q] + "; ");
  96. }
  97.  
  98. switch (talalatok)
  99. {
  100. case 1:
  101. Console.WriteLine("\n\nA nyerőszámok 20%-át találtad el.");
  102. break;
  103. case 2:
  104. Console.WriteLine("\n\nA nyerőszámok 40%-át találtad el.");
  105. break;
  106. case 3:
  107. Console.WriteLine("\n\nA nyerőszámok 60%-át találtad el.");
  108. break;
  109. case 4:
  110. Console.WriteLine("\n\nA nyerőszámok 80%-át találtad el.");
  111. break;
  112. case 5:
  113. Console.WriteLine("\n\nA nyerőszámok 100%-át találtad el.");
  114. break;
  115. default: Console.WriteLine("\n\nA nyerőszámok 0%-át találtad el.");
  116. break;
  117.  
  118. }
  119.  
  120.  
  121. Console.ReadLine();
  122. }
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement