Advertisement
pifka

card games

Feb 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace solutions
  9. {
  10. class Program
  11. {
  12. public static void Main()
  13. {
  14. var firstPlayer = Console.ReadLine().Split().Select(int.Parse).ToList();
  15. var secondPlayer = Console.ReadLine().Split().Select(int.Parse).ToList();
  16.  
  17. var count = 0;
  18. while (true)
  19. {
  20. if (firstPlayer[count] > secondPlayer[count])
  21. {
  22. firstPlayer.Add(firstPlayer[count]);
  23. firstPlayer.Add(secondPlayer[count]);
  24. firstPlayer.RemoveAt(count);
  25. secondPlayer.RemoveAt(count);
  26. }
  27. else if (firstPlayer[count] < secondPlayer[count])
  28. {
  29. secondPlayer.Add(secondPlayer[count]);
  30. secondPlayer.Add(firstPlayer[count]);
  31. firstPlayer.RemoveAt(count);
  32. secondPlayer.RemoveAt(count);
  33. }
  34. else
  35. {
  36. firstPlayer.RemoveAt(count);
  37. secondPlayer.RemoveAt(count);
  38. }
  39. if (firstPlayer.Count == 0 || secondPlayer.Count == 0)
  40. {
  41. break;
  42. }
  43.  
  44. }
  45. if (firstPlayer.Sum() > secondPlayer.Sum())
  46. {
  47. Console.WriteLine($"First player wins! Sum: {firstPlayer.Sum()}");
  48. }
  49. else
  50. {
  51. Console.WriteLine($"Second player wins! Sum: {secondPlayer.Sum()}");
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement