fbinnzhivko

02.000 Basket Battle

May 5th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         string firstPlayer = Console.ReadLine();
  8.         string secondPlayer = "";
  9.         int rounds = int.Parse(Console.ReadLine());
  10.  
  11.         bool win = false;
  12.         Dictionary<string, int> playerPoints = new Dictionary<string, int>();
  13.         playerPoints.Add("Simeon", 0);
  14.         playerPoints.Add("Nakov", 0);
  15.  
  16.         if (firstPlayer == "Nakov"){secondPlayer = "Simeon";}
  17.         else{secondPlayer = "Nakov";}
  18.  
  19.         for (int i = 1; i <= rounds; i++)
  20.         {
  21.             int points = int.Parse(Console.ReadLine());
  22.             string result = Console.ReadLine();
  23.  
  24.             if (result == "success" && playerPoints[firstPlayer] + points <= 500)
  25.             {
  26.                 playerPoints[firstPlayer] += points;
  27.  
  28.                 if (playerPoints[firstPlayer] == 500)
  29.                 {
  30.                     win = true;
  31.                     Console.WriteLine("{0}\n{1}\n{2}",firstPlayer,i, playerPoints[secondPlayer]);
  32.                     break;
  33.                 }
  34.             }
  35.             points = int.Parse(Console.ReadLine());
  36.             result = Console.ReadLine();
  37.  
  38.             if (result == "success" && playerPoints[secondPlayer] + points <= 500)
  39.             {
  40.                 playerPoints[secondPlayer] += points;
  41.  
  42.                 if (playerPoints[secondPlayer] == 500)
  43.                 {
  44.                     win = true;
  45.                     Console.WriteLine("{0}\n{1}\n{2}", secondPlayer, i, playerPoints[firstPlayer]);
  46.                     break;
  47.                 }
  48.             }
  49.             if (firstPlayer == "Nakov")
  50.             {
  51.                 firstPlayer = "Simeon";
  52.                 secondPlayer = "Nakov";
  53.             }
  54.             else
  55.             {
  56.                 firstPlayer = "Nakov";
  57.                 secondPlayer = "Simeon";
  58.             }
  59.         }
  60.         if (!win)
  61.         {
  62.             if (playerPoints[secondPlayer] == playerPoints[firstPlayer])
  63.             {
  64.                 Console.WriteLine("DRAW");
  65.                 Console.WriteLine(playerPoints[secondPlayer]);
  66.             }
  67.             else if (playerPoints[secondPlayer] < playerPoints[firstPlayer])
  68.             {
  69.                 Console.WriteLine(firstPlayer);
  70.                 Console.WriteLine(playerPoints[firstPlayer] - playerPoints[secondPlayer]);
  71.             }
  72.             else
  73.             {
  74.                 Console.WriteLine(secondPlayer);
  75.                 Console.WriteLine(playerPoints[secondPlayer] - playerPoints[firstPlayer]);
  76.             }
  77.         }
  78.     }
  79. }
Add Comment
Please, Sign In to add comment