Advertisement
darighteous1

02. BasketBattle

Mar 31st, 2015
331
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.  
  3. class Basketball
  4. {
  5.     static void Main()
  6.     {
  7.         string firstPlayer = Console.ReadLine();
  8.         string secondPlayer = firstPlayer == "Simeon" ? "Nakov" : "Simeon";
  9.         int numberOfRounds = int.Parse(Console.ReadLine());
  10.  
  11.         int firstPlayerScore = 0;
  12.         int secondPlayerScore = 0;
  13.         bool isFirstPlayer = true;
  14.  
  15.         for (int currentRound = 1; currentRound <= numberOfRounds; currentRound++)
  16.         {
  17.             for (int i = 0; i < 2; i++)
  18.             {
  19.                 int shot = int.Parse(Console.ReadLine());
  20.                 string result = Console.ReadLine();
  21.  
  22.                 if (result == "success")
  23.                 {
  24.                     if (isFirstPlayer && (firstPlayerScore + shot) <= 500)
  25.                     {
  26.                         firstPlayerScore += shot;
  27.                     }
  28.                     if (!isFirstPlayer && (secondPlayerScore + shot) <= 500)
  29.                     {
  30.                         secondPlayerScore += shot;
  31.                     }
  32.                 }
  33.  
  34.                 if (firstPlayerScore == 500)
  35.                 {
  36.                     if (secondPlayerScore == 500)
  37.                     {
  38.                         Console.WriteLine("DRAW");
  39.                         Console.WriteLine(firstPlayerScore);
  40.                     }
  41.                     Console.WriteLine(firstPlayer);
  42.                     Console.WriteLine(currentRound);
  43.                     Console.WriteLine(secondPlayerScore);
  44.                     return;
  45.                 }
  46.                 if (secondPlayerScore == 500)
  47.                 {
  48.                     if (firstPlayerScore == 500)
  49.                     {
  50.                         Console.WriteLine("DRAW");
  51.                         Console.WriteLine(firstPlayerScore);
  52.                     }
  53.                     Console.WriteLine(secondPlayer);
  54.                     Console.WriteLine(currentRound);
  55.                     Console.WriteLine(firstPlayerScore);
  56.                     return;
  57.                 }
  58.                 isFirstPlayer = !isFirstPlayer;
  59.             }
  60.             isFirstPlayer = !isFirstPlayer;
  61.         }
  62.         if (firstPlayerScore == secondPlayerScore)
  63.         {
  64.             Console.WriteLine("DRAW");
  65.             Console.WriteLine(firstPlayerScore);
  66.         }
  67.         if (firstPlayerScore > secondPlayerScore)
  68.         {
  69.             Console.WriteLine(firstPlayer);
  70.             Console.WriteLine(firstPlayerScore - secondPlayerScore);
  71.         }
  72.         if (secondPlayerScore > firstPlayerScore)
  73.         {
  74.             Console.WriteLine(secondPlayer);
  75.             Console.WriteLine(secondPlayerScore - firstPlayerScore);
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement