Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ZAD_VITI
- {
- class Program
- {
- public static Random rand = new Random();
- public static uint nichya = 0;
- //
- public static int countPlayers = 0;
- public static int[] countDice = new int[countPlayers];
- public static uint[] countWinPlayer = new uint[countPlayers];
- //Demid
- public static void rand5()
- {
- countDice = new int[countPlayers];
- for (int i = 0; i < countPlayers-1; i++)
- {
- countDice[i] = (rand.Next(6) + 1) + (rand.Next(6) + 1);
- }
- countDice[countPlayers-1] = rand.Next(12) + 1;
- }
- public static void proverka()
- {
- //Demid
- int max = 0;
- int index = 0, countMax = 0;
- for (int i = 0; i < countPlayers; i++)
- {
- if (countDice[i] > max)
- {
- max = countDice[i];
- index = i;
- countMax = 1;
- }
- else if (countDice[i] == max)
- {
- countMax++;
- }
- }
- if (countMax > 1)
- {
- nichya++;
- }
- else
- {
- countWinPlayer[index]++;
- }
- }
- static void Main(string[] args)
- {
- ConsoleKeyInfo klav;
- do
- {
- long roundAmount = 0;
- do
- Console.WriteLine("Введите число раундов");
- while (!long.TryParse(Console.ReadLine(), out roundAmount));
- do
- Console.WriteLine("Введите число игроков");
- while (!int.TryParse(Console.ReadLine(), out countPlayers));
- countWinPlayer = new uint[countPlayers];
- for (int i=1; i<=roundAmount; i++)
- {
- rand5();
- proverka();
- }
- for (int i = 0; i < countPlayers; i++)
- {
- Console.WriteLine("Количество выйгрышных раундов: {0} - {1}", i + 1, countWinPlayer[i]);
- }
- Console.WriteLine("Количество выйгранных ничьих: {0}", nichya);
- klav = Console.ReadKey(true);
- }
- while (klav.Key != ConsoleKey.Escape);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement