Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace gameNumberWars
- {
- class Program
- {
- static void Main(string[] args)
- {
- string firstname = Console.ReadLine();
- string secondname = Console.ReadLine();
- int counterone = 0;
- int countertwo = 0;
- int resultone = 0;
- int resulttwo = 0;
- string strOne = "";
- string strTwo = "";
- //(Cardone!= "End of game")
- while (true)
- {
- strOne = Console.ReadLine();
- if (strOne == "End of game")
- {
- Console.WriteLine($"{firstname} has {counterone} points");
- Console.WriteLine($"{secondname} has {countertwo} points");
- break;
- }
- strTwo = Console.ReadLine();
- int cardOne = int.Parse(strOne);
- int cardTwo = int.Parse(strTwo);
- if (cardOne > cardTwo)
- {
- resultone = cardOne - cardTwo;
- counterone += resultone;
- }
- if (cardOne < cardTwo)
- {
- resulttwo = cardTwo - cardOne;
- countertwo += resulttwo;
- }
- if (cardOne == cardTwo)
- {
- Console.WriteLine("Number wars!");
- cardOne = int.Parse(Console.ReadLine());
- cardTwo = int.Parse(Console.ReadLine());
- if (cardOne > cardTwo)
- {
- resultone = cardOne - cardTwo;
- Console.WriteLine($"{firstname} is winner with {counterone} points");
- }
- if (cardOne < cardTwo)
- {
- resulttwo = cardTwo - cardOne;
- Console.WriteLine($"{secondname} is winner with {resulttwo} points");
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement