Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 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 ZAD_VITI
  8. {
  9. class Program
  10. {
  11. public static Random rand = new Random();
  12. public static uint nichya = 0;
  13. //
  14. public static int countPlayers = 0;
  15. public static int[] countDice = new int[countPlayers];
  16. public static uint[] countWinPlayer = new uint[countPlayers];
  17.  
  18.  
  19.  
  20. //Demid
  21. public static void rand5()
  22. {
  23. countDice = new int[countPlayers];
  24. for (int i = 0; i < countPlayers-1; i++)
  25. {
  26. countDice[i] = (rand.Next(6) + 1) + (rand.Next(6) + 1);
  27. }
  28. countDice[countPlayers-1] = rand.Next(12) + 1;
  29. }
  30.  
  31. public static void proverka()
  32. {
  33. //Demid
  34. int max = 0;
  35. int index = 0, countMax = 0;
  36. for (int i = 0; i < countPlayers; i++)
  37. {
  38. if (countDice[i] > max)
  39. {
  40. max = countDice[i];
  41. index = i;
  42. countMax = 1;
  43. }
  44. else if (countDice[i] == max)
  45. {
  46. countMax++;
  47. }
  48. }
  49. if (countMax > 1)
  50. {
  51. nichya++;
  52. }
  53. else
  54. {
  55. countWinPlayer[index]++;
  56. }
  57.  
  58. }
  59.  
  60. static void Main(string[] args)
  61. {
  62. ConsoleKeyInfo klav;
  63. do
  64. {
  65. long roundAmount = 0;
  66. do
  67. Console.WriteLine("Введите число раундов");
  68. while (!long.TryParse(Console.ReadLine(), out roundAmount));
  69.  
  70. do
  71. Console.WriteLine("Введите число игроков");
  72. while (!int.TryParse(Console.ReadLine(), out countPlayers));
  73.  
  74. countWinPlayer = new uint[countPlayers];
  75.  
  76. for (int i=1; i<=roundAmount; i++)
  77. {
  78. rand5();
  79. proverka();
  80. }
  81.  
  82. for (int i = 0; i < countPlayers; i++)
  83. {
  84. Console.WriteLine("Количество выйгрышных раундов: {0} - {1}", i + 1, countWinPlayer[i]);
  85.  
  86. }
  87. Console.WriteLine("Количество выйгранных ничьих: {0}", nichya);
  88.  
  89. klav = Console.ReadKey(true);
  90. }
  91. while (klav.Key != ConsoleKey.Escape);
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement