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