Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- class CardWarsBatka
- {
- static void Main()
- {
- BigInteger playerOneFinalScore = 0;
- BigInteger playerTwoFinalScore = 0;
- int playerOneGameScore = 0;
- int playerTwoGameScore = 0;
- int playerOneGamesWin = 0;
- int playerTwoGamseWin = 0;
- string currentCard;
- int intCard;
- bool playerOneXCardDrawn = false;
- bool playerTwoXCardDrawn = false;
- int numberOfGames = int.Parse(Console.ReadLine());
- for (int i = 1; i <= numberOfGames; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- currentCard = Console.ReadLine();
- switch (currentCard)
- {
- case "A":
- playerOneGameScore += 1;
- break;
- case "J":
- playerOneGameScore += 11;
- break;
- case "Q":
- playerOneGameScore += 12;
- break;
- case "K":
- playerOneGameScore += 13;
- break;
- case "Z":
- playerOneFinalScore *= 2;
- break;
- case "Y":
- playerOneFinalScore -= 200;
- break;
- case "X":
- playerOneXCardDrawn = true;
- break;
- default:
- intCard = int.Parse(currentCard);
- playerOneGameScore += (12 - intCard);
- break;
- }
- }
- for (int k = 0; k < 3; k++)
- {
- currentCard = Console.ReadLine();
- switch (currentCard)
- {
- case "A":
- playerTwoGameScore += 1;
- break;
- case "J":
- playerTwoGameScore += 11;
- break;
- case "Q":
- playerTwoGameScore += 12;
- break;
- case "K":
- playerTwoGameScore += 13;
- break;
- case "Z":
- playerTwoFinalScore *= 2;
- break;
- case "Y":
- playerTwoFinalScore -= 200;
- break;
- case "X":
- playerTwoXCardDrawn = true;
- break;
- default:
- intCard = int.Parse(currentCard);
- playerTwoGameScore += (12 - intCard);
- break;
- }
- }
- if (playerOneXCardDrawn && !playerTwoXCardDrawn)
- {
- Console.WriteLine("X card drawn! Player one wins the match!");
- return;
- }
- if (!playerOneXCardDrawn && playerTwoXCardDrawn)
- {
- Console.WriteLine("X card drawn! Player two wins the match!");
- return;
- }
- if (playerOneGameScore > playerTwoGameScore)
- {
- playerOneFinalScore += playerOneGameScore;
- playerOneGamesWin++;
- }
- if (playerTwoGameScore > playerOneGameScore)
- {
- playerTwoFinalScore += playerTwoGameScore;
- playerTwoGamseWin++;
- }
- playerOneGameScore = 0;
- playerTwoGameScore = 0;
- if (playerOneXCardDrawn && playerTwoXCardDrawn)
- {
- playerOneFinalScore += 50;
- playerTwoFinalScore += 50;
- playerOneGameScore = 0;
- playerTwoGameScore = 0;
- playerOneXCardDrawn = false;
- playerTwoXCardDrawn = false;
- continue;
- }
- }
- if (playerOneFinalScore > playerTwoFinalScore)
- {
- Console.WriteLine("First player wins!");
- Console.WriteLine("Score: {0}", playerOneFinalScore);
- Console.WriteLine("Games won: {0}", playerOneGamesWin);
- }
- else if (playerTwoFinalScore > playerOneFinalScore)
- {
- Console.WriteLine("Second player wins!");
- Console.WriteLine("Score: {0}", playerTwoFinalScore);
- Console.WriteLine("Games won: {0}", playerTwoGamseWin);
- }
- else
- {
- Console.WriteLine("It's a tie!");
- Console.WriteLine("Score: {0}", playerTwoFinalScore);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement