Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Poker
- {
- static void Main()
- {
- string card;
- int[] cardsInt = new int[5];
- for (int i = 0; i < 5; i++)
- {
- card = Console.ReadLine();
- switch (card)
- {
- case "J":
- card = "11";
- break;
- case "Q":
- card = "12";
- break;
- case "K":
- card = "13";
- break;
- case "A":
- card = "14";
- break;
- default:
- break;
- }
- cardsInt[i] = int.Parse(card);
- }
- int counter = 0;
- int sum = 0;
- int flag = 0;
- for (int i = 0; i < 5; i++)
- {
- sum += cardsInt[i]; //the sum for straight will always sum%5=0 or 28 for A,2,3,4,5
- for (int j = (i+1); j < 5; j++)
- {
- if (cardsInt[i]==cardsInt[j])
- {
- counter++; //counter for the switch
- }
- if (cardsInt[i] != cardsInt[j])
- {
- flag++; //make sure 5 cards are different
- }
- }
- }
- if (flag == 10 && ((sum % 5 == 0) || sum == 28))
- {
- Console.WriteLine("Straight");
- }
- else
- {
- switch (counter)
- {
- case 0:
- Console.WriteLine("Nothing");
- break;
- case 1:
- Console.WriteLine("One Pair");
- break;
- case 2:
- Console.WriteLine("Two Pairs");
- break;
- case 3:
- Console.WriteLine("Three of a Kind");
- break;
- case 4:
- Console.WriteLine("Full House");
- break;
- case 6:
- Console.WriteLine("Four of a Kind");
- break;
- case 10:
- Console.WriteLine("Impossible");
- break;
- default:
- Console.WriteLine("Nothing");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement