Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main()
- {
- int numberOfGames = int.Parse(Console.ReadLine());
- //string[] firstPlayerCards = new string[3];
- //string[] secondPlayerCards = new string[3];
- List<string> firstPlayerCards = new List<string>();
- List<string> secondPlayerCards = new List<string>();
- int firtstPlayerHand = 0;
- int secondPlayerHand = 0;
- int firtstPlayerScore = 0;
- int secondPlayerScore = 0;
- int firstPlayerWons = 0;
- int secondPlayerWons = 0;
- int firstZCounter = 1;
- int secondZCounter = 1;
- int firstYCounter = 0;
- int secondYCounter = 0;
- bool firstX = false;
- bool secondX = false;
- for (int i = 0; i < numberOfGames; i++)
- {
- firtstPlayerHand = 0;
- secondPlayerHand = 0;
- firstYCounter = 1;
- secondYCounter = 1;
- firstZCounter = 1;
- secondZCounter = 1;
- firstPlayerCards.Clear();
- secondPlayerCards.Clear();
- firstPlayerCards.Add(Console.ReadLine());
- firstPlayerCards.Add(Console.ReadLine());
- firstPlayerCards.Add(Console.ReadLine());
- secondPlayerCards.Add(Console.ReadLine());
- secondPlayerCards.Add(Console.ReadLine());
- secondPlayerCards.Add(Console.ReadLine());
- if (firstPlayerCards.Contains("X") && !secondPlayerCards.Contains("X"))
- {
- firstX = true;
- break;
- }
- if (!firstPlayerCards.Contains("X") && secondPlayerCards.Contains("X"))
- {
- secondX = true;
- break;
- }
- if (firstPlayerCards.Contains("X") && secondPlayerCards.Contains("X"))
- {
- firtstPlayerScore += 50;
- secondPlayerScore += 50;
- }
- for (int j = 0; j < 3; j++)
- {
- switch (firstPlayerCards[j])
- {
- case "2": firtstPlayerHand += 10; break;
- case "3": firtstPlayerHand += 9; break;
- case "4": firtstPlayerHand += 8; break;
- case "5": firtstPlayerHand += 7; break;
- case "6": firtstPlayerHand += 6; break;
- case "7": firtstPlayerHand += 5; break;
- case "8": firtstPlayerHand += 4; break;
- case "9": firtstPlayerHand += 3; break;
- case "10": firtstPlayerHand += 2; break;
- case "A": firtstPlayerHand += 1; break;
- case "J": firtstPlayerHand += 11; break;
- case "Q": firtstPlayerHand += 12; break;
- case "K": firtstPlayerHand += 13; break;
- case "Z": firtstPlayerScore = (int)(firtstPlayerScore * Math.Pow(2, firstZCounter)); firstZCounter++; break;
- case "Y": firtstPlayerScore -= 200 * firstZCounter; firstYCounter++; break;
- }
- switch (secondPlayerCards[j])
- {
- case "2": secondPlayerHand += 10; break;
- case "3": secondPlayerHand += 9; break;
- case "4": secondPlayerHand += 8; break;
- case "5": secondPlayerHand += 7; break;
- case "6": secondPlayerHand += 6; break;
- case "7": secondPlayerHand += 5; break;
- case "8": secondPlayerHand += 4; break;
- case "9": secondPlayerHand += 3; break;
- case "10": secondPlayerHand += 2; break;
- case "A": secondPlayerHand += 1; break;
- case "J": secondPlayerHand += 11; break;
- case "Q": secondPlayerHand += 12; break;
- case "K": secondPlayerHand += 13; break;
- case "Z": secondPlayerScore = (int)(secondPlayerScore * Math.Pow(2, secondZCounter)); secondZCounter++; break;
- case "Y": secondPlayerScore -= 200 * secondYCounter; secondYCounter++; break;
- }
- }
- if (firtstPlayerHand > secondPlayerHand)
- {
- firtstPlayerScore += firtstPlayerHand;
- firstPlayerWons += 1;
- }
- else if (firtstPlayerHand < secondPlayerHand)
- {
- secondPlayerScore += secondPlayerHand;
- secondPlayerWons += 1;
- }
- }
- if (!firstX && !secondX)
- {
- if (firtstPlayerScore > secondPlayerScore)
- {
- Console.WriteLine("First player wins!");
- Console.WriteLine("Score: {0}", firtstPlayerScore);
- Console.WriteLine("Games won: {0}", firstPlayerWons);
- }
- else if (firtstPlayerScore < secondPlayerScore)
- {
- Console.WriteLine("Second player wins!");
- Console.WriteLine("Score: {0}", secondPlayerScore);
- Console.WriteLine("Games won: {0}", secondPlayerWons);
- }
- else
- {
- Console.WriteLine("It's a tie!");
- Console.WriteLine("Score: {0}", secondPlayerScore);
- }
- }
- if (firstX && !secondX)
- {
- Console.WriteLine("X card drawn! Player one wins the match!");
- }
- if (!firstX && secondX)
- {
- Console.WriteLine("X card drawn! Player two wins the match!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement