Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Game_Number_Wars
- {
- class Program
- {
- static void Main(string[] args)
- {
- string gamer1 = Console.ReadLine();//ОТ КОНЗОЛАТА
- string gamer2 = Console.ReadLine();//
- int totalGamer1 = 0;
- int totalGamer2 = 0;
- string command = Console.ReadLine();//команда се въвежда от конзолата
- bool IsNumberWars = false;
- while (command != "End of game")
- {
- int card1 = int.Parse(command);// вътре в цикъла . като започва с команда
- int card2 = int.Parse(Console.ReadLine());
- if (card1 > card2)//първия е победител
- {
- totalGamer1 += card1 - card2;
- }
- else if (card2 > card1)
- {
- totalGamer2 += card2 - card1;
- }
- else//булевия израз става true ,заради команда number wars
- {
- IsNumberWars = true;
- card1 = int.Parse(Console.ReadLine());
- card2 = int.Parse(Console.ReadLine());
- if (card1 > card2)
- {
- card1 = card1 - card2;
- totalGamer1 = card1;
- Console.WriteLine($"Number wars!");
- Console.WriteLine($"{gamer1} is winner with {totalGamer1} points");
- break;
- }
- else
- {
- card2 = card2 - card1;
- totalGamer2 = card2;
- Console.WriteLine($"Number wars!");
- Console.WriteLine($"{gamer2} is winner with {totalGamer2} points");
- break;
- }
- }
- command = Console.ReadLine();
- }
- if (command == "End of game")
- {
- Console.WriteLine($"{gamer1} has {totalGamer1} points");
- Console.WriteLine($"{gamer2} has {totalGamer2} points");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement