Advertisement
Guest User

Untitled

a guest
May 24th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Game_Number_Wars
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string gamer1 = Console.ReadLine();//ОТ КОНЗОЛАТА
  10. string gamer2 = Console.ReadLine();//
  11.  
  12. int totalGamer1 = 0;
  13. int totalGamer2 = 0;
  14.  
  15. string command = Console.ReadLine();//команда се въвежда от конзолата
  16. bool IsNumberWars = false;
  17.  
  18. while (command != "End of game")
  19. {
  20. int card1 = int.Parse(command);// вътре в цикъла . като започва с команда
  21. int card2 = int.Parse(Console.ReadLine());
  22. if (card1 > card2)//първия е победител
  23. {
  24. totalGamer1 += card1 - card2;
  25. }
  26. else if (card2 > card1)
  27. {
  28. totalGamer2 += card2 - card1;
  29. }
  30. else//булевия израз става true ,заради команда number wars
  31. {
  32. IsNumberWars = true;
  33. card1 = int.Parse(Console.ReadLine());
  34. card2 = int.Parse(Console.ReadLine());
  35.  
  36. if (card1 > card2)
  37. {
  38.  
  39. card1 = card1 - card2;
  40. totalGamer1 = card1;
  41. Console.WriteLine($"Number wars!");
  42. Console.WriteLine($"{gamer1} is winner with {totalGamer1} points");
  43. break;
  44. }
  45. else
  46. {
  47.  
  48. card2 = card2 - card1;
  49. totalGamer2 = card2;
  50. Console.WriteLine($"Number wars!");
  51. Console.WriteLine($"{gamer2} is winner with {totalGamer2} points");
  52. break;
  53. }
  54.  
  55.  
  56. }
  57. command = Console.ReadLine();
  58.  
  59. }
  60.  
  61. if (command == "End of game")
  62. {
  63. Console.WriteLine($"{gamer1} has {totalGamer1} points");
  64. Console.WriteLine($"{gamer2} has {totalGamer2} points");
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement