Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Poker
- {
- static void Main()
- {
- string [] c={"A","2","3","4","5","6","7","8","9","10","J","Q","K","A"};
- string[] inpt =new string[5];
- int i=0,j=0,k=0,m=0;
- for (i = 0; i < 5; i++)
- {
- inpt[i] = Console.ReadLine();
- }
- int cnt2=0;
- bool four = false, three=false, pair=false;
- int a = -1, b = -1, a1 = -1, b1 = -1;
- bool ace=false, c2=false,c3=false, c4=false, c5=false, c10=false,cj=false, cq=false,ck=false;
- if(inpt[0].Equals(inpt[1])&&inpt[1].Equals(inpt[2])&&inpt[2].Equals(inpt[3])&&inpt[3].Equals(inpt[4]))
- {
- Console.WriteLine("Impossible");
- }
- else
- {
- for (i = 0; i < 2; i++)
- {
- for (j = i + 1; j < 3; j++)
- {
- for (k = j + 1; k < 4; k++)
- {
- for (m = k + 1; m < 5; m++)
- {
- if (inpt[i].Equals(inpt[j]) && inpt[j].Equals(inpt[k]) && inpt[k].Equals(inpt[m]))
- {
- four = true;
- Console.WriteLine("Four of a Kind");
- break;
- }
- }
- }
- }
- }
- if (four == false)
- {
- for (i = 0; i < 4; i++)
- {
- for (j = i + 1; j < 5; j++)
- {
- if (inpt[i].Equals(inpt[j]))
- {
- cnt2++;
- if (a == -1 && b == -1)
- {
- a = i;
- b = j;
- }
- else
- {
- a1 = i;
- b1=j;
- }
- }
- }
- }
- for (i = 0; i < 3; i++)
- {
- for (j = i + 1; j < 4; j++)
- {
- for (k = j + 1; k < 5; k++)
- {
- if (inpt[i].Equals(inpt[j]) && inpt[j].Equals(inpt[k]))
- {
- three = true;
- }
- }
- }
- }
- if (three == true)
- {
- if (cnt2 <= 3) Console.WriteLine("Three of a Kind");
- else if (cnt2 == 4) Console.WriteLine("Full House");
- }
- else
- {
- if (a != -1 || a1 != -1)
- {
- if (inpt[a].Equals( inpt[a1]))
- {
- if (inpt[b].Equals( inpt[b1])) pair = true;
- }
- else if (inpt[a].Equals( inpt[b1]))
- {
- if (inpt[b].Equals(inpt[a1])) pair = true;
- }
- }
- if (pair == true)
- {
- Console.WriteLine("Two Pairs");
- }
- else if (cnt2!=0) Console.WriteLine("One Pair");
- }
- for (int p = 0; p < 5; p++)
- {
- if (inpt[p] == "A"&&ace==false)
- {
- ace = true;
- }
- if (inpt[p] == "2" && c2 == false)
- {
- c2 = true;
- }
- if (inpt[p] == "3" && c3 == false)
- {
- c3 = true;
- }
- if (inpt[p] == "4" && c4 == false)
- {
- c4 = true;
- }
- if (inpt[p] == "5" && c5 == false)
- {
- c5 = true;
- }
- if (inpt[p] == "10" && c10 == false)
- {
- c10 = true;
- }
- if (inpt[p] == "J" && cj == false)
- {
- cj = true;
- }
- if (inpt[p] == "Q" && cq == false)
- {
- cq = true;
- }
- if (inpt[p] == "K" && ck == false)
- {
- ck = true;
- }
- }
- if ((ace && c2 && c3 && c4 && c5)||(ace && c10 && cj && cq && ck)) Console.WriteLine("Straight");
- else if (cnt2==0&&!four&&!three) Console.WriteLine("Nothing");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment