Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 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 int userinput = 0;
  12. static int[] userszamok = new int[5];
  13. static int[] sorsoltszamok = new int[5];
  14. static int sorsolt = 0;
  15. static bool egyenlo = false;
  16. static Random rnd = new Random();
  17. static void Main(string[] args)
  18. {
  19.  
  20.  
  21. int talalatok = 0;
  22.  
  23.  
  24.  
  25. userSzamokBeker();
  26. Console.WriteLine("\n\nTehát a tippjeid: ");
  27. rendezes(userszamok);
  28. nyeroSzamokSorsol();
  29. Console.WriteLine("\n\nA nyerőszámok: ");
  30. rendezes(sorsoltszamok);
  31.  
  32.  
  33.  
  34.  
  35.  
  36. for (int m = 0; m < userszamok.Length; m++)
  37. {
  38. for (int n = 0; n < sorsoltszamok.Length; n++)
  39. {
  40. if (userszamok[m] == sorsoltszamok[n])
  41. {
  42. talalatok++;
  43. }
  44.  
  45. }
  46.  
  47. }
  48. Console.WriteLine("\n\nA találataid száma: " + talalatok);
  49.  
  50. int tmp;
  51. int a = sorsoltszamok.Length;
  52. for (int o = a - 1; o > 0; o--)
  53. {
  54. for (int p = 0; p < o; p++)
  55. {
  56. if (sorsoltszamok[p] > sorsoltszamok[p + 1])
  57. {
  58. tmp = sorsoltszamok[p];
  59. sorsoltszamok[p] = sorsoltszamok[p + 1];
  60. sorsoltszamok[p + 1] = tmp;
  61.  
  62. }
  63.  
  64. }
  65.  
  66. }
  67.  
  68. switch (talalatok)
  69. {
  70. case 1:
  71. Console.WriteLine("\n\nA nyerőszámok 20%-át találtad el.");
  72. break;
  73. case 2:
  74. Console.WriteLine("\n\nA nyerőszámok 40%-át találtad el.");
  75. break;
  76. case 3:
  77. Console.WriteLine("\n\nA nyerőszámok 60%-át találtad el.");
  78. break;
  79. case 4:
  80. Console.WriteLine("\n\nA nyerőszámok 80%-át találtad el.");
  81. break;
  82. case 5:
  83. Console.WriteLine("\n\nA nyerőszámok 100%-át találtad el.");
  84. break;
  85. default:
  86. Console.WriteLine("\n\nA nyerőszámok 0%-át találtad el.");
  87. break;
  88.  
  89. }
  90.  
  91.  
  92. Console.ReadLine();
  93. }
  94.  
  95. private static void rendezes(int[] tomb)
  96. {
  97. Array.Sort(tomb);
  98. for (int i = 0; i < 5; i++)
  99. {
  100. Console.Write(tomb[i]+", ");
  101. }
  102. }
  103.  
  104. private static void nyeroSzamokSorsol()
  105. {
  106. for (int k = 0; k < sorsoltszamok.Length; k++)
  107. {
  108.  
  109. sorsolt = rnd.Next(1, 20);
  110. for (int l = 0; l < sorsoltszamok.Length; l++)
  111. {
  112. egyenlo = false;
  113. if (sorsoltszamok[l] == sorsolt)
  114. {
  115. egyenlo = true;
  116. k--;
  117. break;
  118. }
  119.  
  120. }
  121. if (egyenlo == false)
  122. {
  123. sorsoltszamok[k] = sorsolt;
  124.  
  125. }
  126.  
  127. }
  128. }
  129.  
  130. private static void userSzamokBeker()
  131. {
  132. Console.WriteLine("Kérem a tippeket: ");
  133. for (int i = 0; i < userszamok.Length; i++)
  134. {
  135. userinput = int.Parse(Console.ReadLine());
  136. for (int j = 0; j < userszamok.Length; j++)
  137. {
  138. if (userszamok[j] == userinput)
  139. {
  140. Console.WriteLine("ez már volt");
  141. i--;
  142. break;
  143. }
  144.  
  145. }
  146. userszamok[i] = userinput;
  147. }
  148. }
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement