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;
- using System.Numerics;
- class Program
- {
- static void Main()
- {
- int games = int.Parse(Console.ReadLine());
- int cards = games * 6;
- string[] input = new string[cards];
- for (int i = 0; i < cards; i++)
- {
- input[i] = Console.ReadLine();
- }
- int gameCount = 0;
- int[] array = new int[cards];
- for (int i = 0; i < cards; i++)
- {
- switch (input[i])
- {
- case "2": array[i] = 10;
- break;
- case "3": array[i] = 9;
- break;
- case "4": array[i] = 8;
- break;
- case "5": array[i] = 7;
- break;
- case "6": array[i] = 6;
- break;
- case "7": array[i] = 5;
- break;
- case "8": array[i] = 4;
- break;
- case "9": array[i] = 3;
- break;
- case "10": array[i] = 2;
- break;
- case "J": array[i] = 11;
- break;
- case "Q": array[i] = 12;
- break;
- case "K": array[i] = 13;
- break;
- case "A": array[i] = 1;
- break;
- case "Z": array[i] = 20;
- break;
- case "Y": array[i] = 30;
- break;
- case "X": array[i] = 40;
- break;
- }
- }
- BigInteger playerOneScore = 0;
- BigInteger playerTwoScore = 0;
- BigInteger playerOneGameScore = 0;
- BigInteger playerTwoGameScore = 0;
- int cardcount = 0;
- int gamesWon1 = 0;
- int gamesWon2 = 0;
- int oneHaveX = 0;
- int twoHaveX = 0;
- int onezCount = 0;
- int oneyCount = 0;
- int twozCount = 0;
- int twoyCount = 0;
- int j = 0;
- for (int i = 1; i <= games; i++)
- {
- cardcount = i * 6;
- playerOneScore = 0;
- playerTwoScore = 0;
- oneHaveX = 0;
- twoHaveX = 0;
- onezCount = 0;
- twozCount = 0;
- oneyCount = 0;
- twoyCount = 0;
- while ((gameCount < (cardcount)) && (j < cardcount))
- {
- if (j < cardcount - 3)
- {
- if (array[j] < 20)
- {
- playerOneScore += array[j];
- }
- else if (array[j] == 20)
- {
- onezCount++;
- }
- else if (array[j] == 30)
- {
- oneyCount++;
- }
- else if (array[j] == 40)
- {
- oneHaveX = 1;
- }
- }
- else
- {
- if (array[j] < 20)
- {
- playerTwoScore += array[j];
- }
- else if (array[j] == 20)
- {
- twozCount++;
- }
- else if (array[j] == 30)
- {
- twoyCount++;
- }
- else if (array[j] == 40)
- {
- twoHaveX = 1;
- }
- }
- j++;
- }
- if (oneyCount >= 1)
- {
- playerOneGameScore -= (oneyCount * 200);
- }
- if (onezCount >= 1)
- {
- playerOneGameScore *= ((int)Math.Pow(2, onezCount));
- }
- if (twoyCount >= 1)
- {
- playerTwoGameScore -= (twoyCount * 200);
- }
- if (twozCount >= 1)
- {
- playerTwoGameScore *= ((int)Math.Pow(2, twozCount));
- }
- if (((oneHaveX != 0) && (twoHaveX != 0)) && (oneHaveX == twoHaveX))
- {
- playerOneGameScore += 50;
- playerTwoGameScore += 50;
- }
- else if (((oneHaveX != 0) || (twoHaveX != 0)) && (oneHaveX != twoHaveX))
- {
- if ((oneHaveX != 0) && (oneHaveX > twoHaveX))
- {
- Console.WriteLine("X card drawn! Player one wins the match!");
- break;
- }
- else if((twoHaveX != 0) && (twoHaveX > oneHaveX))
- {
- Console.WriteLine("X card drawn! Player two wins the match!");
- break;
- }
- }
- gameCount += 6;
- if (playerOneScore > playerTwoScore)
- {
- gamesWon1++;
- playerOneGameScore += playerOneScore;
- }
- else if (playerTwoScore > playerOneScore)
- {
- gamesWon2++;
- playerTwoGameScore += playerTwoScore;
- }
- else if (playerOneScore == playerTwoScore)
- {
- playerOneScore = 0;
- playerTwoScore = 0;
- }
- }
- if (oneHaveX == twoHaveX)
- {
- if (playerOneGameScore > playerTwoGameScore)
- {
- Console.WriteLine("First player wins!");
- Console.WriteLine("Score: " + playerOneGameScore);
- Console.WriteLine("Games won: " + gamesWon1);
- }
- else if (playerTwoGameScore > playerOneGameScore)
- {
- Console.WriteLine("Second player wins!");
- Console.WriteLine("Score: " + playerTwoGameScore);
- Console.WriteLine("Games won: " + gamesWon2);
- }
- else if (playerOneGameScore == playerTwoGameScore)
- {
- Console.WriteLine("It's a tie!");
- Console.WriteLine("Score: " + playerOneGameScore);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement