ellapt

Poker

Dec 29th, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. using System;
  2. class Poker
  3. {
  4. static void Main()
  5. {
  6. string [] c={"A","2","3","4","5","6","7","8","9","10","J","Q","K","A"};
  7. string[] inpt =new string[5];
  8. int i=0,j=0,k=0,m=0;
  9. for (i = 0; i < 5; i++)
  10. {
  11. inpt[i] = Console.ReadLine();
  12. }
  13.  
  14. int cnt2=0;
  15. bool four = false, three=false, pair=false;
  16. int a = -1, b = -1, a1 = -1, b1 = -1;
  17.  
  18. bool ace=false, c2=false,c3=false, c4=false, c5=false, c10=false,cj=false, cq=false,ck=false;
  19.  
  20. if(inpt[0].Equals(inpt[1])&&inpt[1].Equals(inpt[2])&&inpt[2].Equals(inpt[3])&&inpt[3].Equals(inpt[4]))
  21. {
  22. Console.WriteLine("Impossible");
  23. }
  24. else
  25. {
  26. for (i = 0; i < 2; i++)
  27. {
  28. for (j = i + 1; j < 3; j++)
  29. {
  30. for (k = j + 1; k < 4; k++)
  31. {
  32. for (m = k + 1; m < 5; m++)
  33. {
  34. if (inpt[i].Equals(inpt[j]) && inpt[j].Equals(inpt[k]) && inpt[k].Equals(inpt[m]))
  35. {
  36. four = true;
  37. Console.WriteLine("Four of a Kind");
  38. break;
  39. }
  40. }
  41. }
  42.  
  43. }
  44. }
  45. if (four == false)
  46. {
  47. for (i = 0; i < 4; i++)
  48. {
  49. for (j = i + 1; j < 5; j++)
  50. {
  51. if (inpt[i].Equals(inpt[j]))
  52. {
  53. cnt2++;
  54. if (a == -1 && b == -1)
  55. {
  56. a = i;
  57. b = j;
  58. }
  59. else
  60. {
  61. a1 = i;
  62. b1=j;
  63. }
  64. }
  65. }
  66. }
  67. for (i = 0; i < 3; i++)
  68. {
  69. for (j = i + 1; j < 4; j++)
  70. {
  71. for (k = j + 1; k < 5; k++)
  72. {
  73. if (inpt[i].Equals(inpt[j]) && inpt[j].Equals(inpt[k]))
  74. {
  75. three = true;
  76. }
  77. }
  78. }
  79. }
  80. if (three == true)
  81. {
  82. if (cnt2 <= 3) Console.WriteLine("Three of a Kind");
  83. else if (cnt2 == 4) Console.WriteLine("Full House");
  84. }
  85. else
  86. {
  87. if (a != -1 || a1 != -1)
  88. {
  89. if (inpt[a].Equals( inpt[a1]))
  90. {
  91. if (inpt[b].Equals( inpt[b1])) pair = true;
  92. }
  93. else if (inpt[a].Equals( inpt[b1]))
  94. {
  95. if (inpt[b].Equals(inpt[a1])) pair = true;
  96. }
  97. }
  98. if (pair == true)
  99. {
  100. Console.WriteLine("Two Pairs");
  101. }
  102. else if (cnt2!=0) Console.WriteLine("One Pair");
  103. }
  104. for (int p = 0; p < 5; p++)
  105. {
  106. if (inpt[p] == "A"&&ace==false)
  107. {
  108. ace = true;
  109. }
  110. if (inpt[p] == "2" && c2 == false)
  111. {
  112. c2 = true;
  113. }
  114. if (inpt[p] == "3" && c3 == false)
  115. {
  116. c3 = true;
  117. }
  118. if (inpt[p] == "4" && c4 == false)
  119. {
  120. c4 = true;
  121. }
  122. if (inpt[p] == "5" && c5 == false)
  123. {
  124. c5 = true;
  125. }
  126. if (inpt[p] == "10" && c10 == false)
  127. {
  128. c10 = true;
  129. }
  130. if (inpt[p] == "J" && cj == false)
  131. {
  132. cj = true;
  133. }
  134. if (inpt[p] == "Q" && cq == false)
  135. {
  136. cq = true;
  137. }
  138. if (inpt[p] == "K" && ck == false)
  139. {
  140. ck = true;
  141. }
  142. }
  143. if ((ace && c2 && c3 && c4 && c5)||(ace && c10 && cj && cq && ck)) Console.WriteLine("Straight");
  144. else if (cnt2==0&&!four&&!three) Console.WriteLine("Nothing");
  145. }
  146.  
  147. }
  148.  
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment