Advertisement
Guest User

02. Basket Battle (Basics Exam 29 March 2015 Morning)

a guest
Mar 27th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _01._01._02.BasketBattle
  5. {
  6.     class Program
  7.     {
  8.         static string OtherPleyar(string curPlayer)
  9.         {
  10.             return curPlayer == "Nakov" ? "Simeon" : "Nakov";
  11.         }
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             string curPlayer = Console.ReadLine();
  16.             int numOfRound_N = int.Parse(Console.ReadLine());
  17.             Dictionary<string, int> allPoint = new Dictionary<string, int>() { { "Nakov", 0 }, { "Simeon", 0 } };
  18.             bool isWiner = false;
  19.  
  20.             int round;
  21.             for (round = 1; round <= numOfRound_N; round++)
  22.             {
  23.                 string firstPlayer = curPlayer;
  24.                 int trayPoints_P = int.Parse(Console.ReadLine());
  25.                 int firstPlayerPoint = trayPoints_P;
  26.                 allPoint[firstPlayer] += Console.ReadLine() == "success" ? firstPlayerPoint : 0;
  27.                 isWiner = allPoint[curPlayer] == 500;
  28.                 if (isWiner) break;
  29.  
  30.                 curPlayer = OtherPleyar(firstPlayer);
  31.  
  32.                 string secondPlayer = curPlayer;
  33.                 trayPoints_P = int.Parse(Console.ReadLine());
  34.                 int secondPlayerPoint = trayPoints_P;
  35.                 allPoint[secondPlayer] += Console.ReadLine() == "success"  ? secondPlayerPoint : 0;
  36.                 isWiner = allPoint[curPlayer] == 500;
  37.                 if (isWiner) break;
  38.  
  39.                 allPoint[firstPlayer] -= allPoint[firstPlayer] > 500 ? firstPlayerPoint : 0;
  40.                 allPoint[secondPlayer] -= allPoint[secondPlayer] > 500 ? secondPlayerPoint : 0;
  41.             }
  42.  
  43.             if (isWiner)
  44.             {
  45.                 Console.WriteLine(curPlayer);
  46.                 Console.WriteLine(round);
  47.                 Console.WriteLine(allPoint[OtherPleyar(curPlayer)]);
  48.             }
  49.             else if (allPoint["Nakov"] == allPoint["Simeon"])
  50.             {
  51.                 Console.WriteLine("DRAW");
  52.                 Console.WriteLine(allPoint["Nakov"]);
  53.             }
  54.             else
  55.             {
  56.                 curPlayer = allPoint["Nakov"] > allPoint["Simeon"] ? "Nakov" : "Simeon";
  57.                 Console.WriteLine(curPlayer);
  58.                 Console.WriteLine(Math.Abs(allPoint["Nakov"] - allPoint["Simeon"]));
  59.             }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement