Advertisement
Guest User

Untitled

a guest
Oct 21st, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. using System;
  2.  
  3. class BasketBattle
  4. {
  5. static void Main()
  6. {
  7. string firstPlayerName = Console.ReadLine();
  8. int rounds = int.Parse(Console.ReadLine());
  9.  
  10. string secondPlayerName = firstPlayerName == "Nakov" ? "Simeon" : "Nakov";
  11. int firstPlayerPoints = 0;
  12. int secondPlayerPoints = 0;
  13. int winningRound = 0;
  14. string winner = string.Empty;
  15. int looserPoints = 0;
  16. int lessPoints = 0;
  17. bool isReaching500 = false;
  18.  
  19. for (int i = 0; i < rounds; i++)
  20. {
  21. for (int j = 0; j < 2; j++)
  22. {
  23. int points = int.Parse(Console.ReadLine());
  24. string attemptResult = Console.ReadLine().Trim();
  25.  
  26. if (attemptResult == "success" && j == 0 && i % 2 == 0)
  27. {
  28. if (firstPlayerPoints + points <= 500)
  29. {
  30. firstPlayerPoints += points;
  31. }
  32.  
  33. }
  34. else if (attemptResult == "success" && j == 1 && i % 2 != 0)
  35. {
  36. if (firstPlayerPoints + points <= 500)
  37. {
  38. firstPlayerPoints += points;
  39. }
  40.  
  41. }
  42. else if (attemptResult == "success" && j == 0 && i % 2 != 0)
  43. {
  44. if (secondPlayerPoints + points <= 500)
  45. {
  46. secondPlayerPoints += points;
  47. }
  48.  
  49. }
  50. else if (attemptResult == "success" && j == 1 && i % 2 == 0)
  51. {
  52. if (secondPlayerPoints + points <= 500)
  53. {
  54. secondPlayerPoints += points;
  55. }
  56. }
  57. }
  58.  
  59. winningRound++;
  60.  
  61. if (firstPlayerPoints == 500 || secondPlayerPoints == 500)
  62. {
  63. isReaching500 = true;
  64. break;
  65. }
  66. }
  67.  
  68. winner = firstPlayerPoints > secondPlayerPoints ? firstPlayerName : secondPlayerName;
  69. looserPoints = Math.Abs(firstPlayerPoints - secondPlayerPoints);
  70. lessPoints = Math.Min(firstPlayerPoints, secondPlayerPoints);
  71. if (firstPlayerPoints != secondPlayerPoints && isReaching500)
  72. {
  73. Console.WriteLine(winner);
  74. Console.WriteLine(winningRound);
  75. Console.WriteLine(lessPoints);
  76. }
  77. else if (firstPlayerPoints != secondPlayerPoints && !isReaching500)
  78. {
  79. Console.WriteLine(winner);
  80. Console.WriteLine(looserPoints);
  81. }
  82. else if (firstPlayerPoints == secondPlayerPoints)
  83. {
  84. Console.WriteLine("DRAW");
  85. Console.WriteLine(firstPlayerPoints);
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement