Guest User

Untitled

a guest
Jun 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static int[] randomszamok = new int[5];
  11. static int[] tipp = new int[5];
  12. static int tipp1;
  13. static int tipp2;
  14. static int tipp3;
  15. static int tipp4;
  16. static int tipp5;
  17. static int talalat = 0;
  18.  
  19. static void Main(string[] args)
  20. {
  21. {
  22.  
  23.  
  24. Random rnd = new Random();
  25. for (int i = 0; i < 5; i++)
  26. {
  27. randomszamok[i] = rnd.Next(1, 38);
  28. }
  29.  
  30.  
  31.  
  32.  
  33. tippbekeres();
  34. }
  35. }
  36. static void tippbekeres()
  37. {
  38.  
  39.  
  40. bool done = false;
  41. do
  42. {
  43. try
  44. {
  45. int c = 1;
  46.  
  47. for (int i = 0; i < 5; i++ )
  48. {
  49. Console.WriteLine("Add meg a(z)" + c++ + "-edik tipped!(1-től 38-ig) ");
  50. tipp[i] = Convert.ToInt16(Console.ReadLine());
  51. if (tipp[i] > 38 || tipp[i]<0)
  52. {
  53. Console.WriteLine("A tippnek 0 és 38 között kell lennie!");
  54. Console.ReadLine();
  55. }
  56.  
  57.  
  58. }
  59. talalatok();
  60. }
  61.  
  62. catch (FormatException)
  63. {
  64. Console.WriteLine("Csak számot adhatsz meg!");
  65. continue;
  66. }
  67.  
  68.  
  69. tipp1 = tipp[0];
  70. tipp2 = tipp[1];
  71. tipp3 = tipp[2];
  72. tipp4 = tipp[3];
  73. tipp5 = tipp[4];
  74.  
  75.  
  76. } while (!done);
  77.  
  78.  
  79. }
  80. static void talalatok()
  81. {
  82.  
  83. for (int i = 0; i < 5; i++)
  84. {
  85.  
  86.  
  87. if (tipp[0] == randomszamok[i] || tipp[1] == randomszamok[i] || tipp[2] == randomszamok[i] || tipp[3] == randomszamok[i] || tipp[4] == randomszamok[i])
  88. {
  89. talalat++;
  90. }
  91.  
  92.  
  93. }
  94.  
  95. Console.WriteLine("Ennyi találatod lett:" + talalat);
  96. Console.WriteLine("A kitalált számok:");
  97. Console.WriteLine(randomszamok[0]);
  98. Console.WriteLine(randomszamok[1]);
  99. Console.WriteLine(randomszamok[2]);
  100. Console.WriteLine(randomszamok[3]);
  101. Console.WriteLine(randomszamok[4]);
  102.  
  103. Console.ReadKey();
  104.  
  105. }
  106. }
  107. }
Add Comment
Please, Sign In to add comment