Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CardGame
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> playerOne = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse)
- .ToList();
- List<int> playerTwo = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse)
- .ToList();
- while (true)
- {
- if (playerOne[0] > playerTwo[0])
- {
- playerOne.Add(playerOne[0]);
- playerOne.Add(playerTwo[0]);
- }
- else if (playerOne[0] < playerTwo[0])
- {
- playerTwo.Add(playerOne[0]);
- playerTwo.Add(playerTwo[0]);
- }
- playerOne.Remove(playerOne[0]);
- playerTwo.Remove(playerTwo[0]);
- if (playerOne.Count == 0)
- {
- Console.WriteLine("Second player wins! Sum: {0}", playerTwo.Sum());
- break;
- }
- else if(playerTwo.Count == 0)
- {
- Console.WriteLine("First player wins! Sum: {0}", playerOne.Sum());
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement