Advertisement
vlad0

Poker-bdcoder29DEC2012

Dec 30th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _03.Poker
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.  
  13.             int[,] deck = new int[15, 1];
  14.                
  15.             for (int i = 0; i < 5; i++)
  16.             {
  17.                 string str = Console.ReadLine();
  18.                 if (str == "J")
  19.                 {
  20.                     deck[11, 0]++;
  21.                 }
  22.                 else if (str == "Q")
  23.                 {
  24.                     deck[12, 0]++;
  25.                 }
  26.                 else if (str == "K")
  27.                 {
  28.                     deck[13, 0]++;
  29.                 }
  30.                 else if (str == "A")
  31.                 {
  32.                     deck[14, 0]++;
  33.                     deck[1, 0]++;
  34.                 }
  35.                 else
  36.                 {
  37.                     int card = int.Parse(str);
  38.                     deck[card, 0]++;
  39.                 }
  40.             }
  41.  
  42.             int triple = 0;
  43.             int pair = 0;
  44.             int straight = 0;
  45.  
  46.             for (int j = 2; j < 15; j++)
  47.             {
  48.                 if (deck[j, 0] == 5)
  49.                 {
  50.                     Console.WriteLine("Impossible");
  51.                     return;
  52.                 }
  53.                 else if (deck[j, 0] == 4)
  54.                 {
  55.                     Console.WriteLine("Four of a Kind");
  56.                     return;
  57.                 }
  58.                 else if (deck[j, 0] == 3)
  59.                 {
  60.                     triple++;
  61.                 }
  62.                 else if (deck[j, 0] == 2)
  63.                 {
  64.                     pair++;
  65.                 }
  66.  
  67.             }
  68.  
  69.  
  70.             if (triple == 1 && pair == 1)
  71.             {
  72.                 Console.WriteLine("Full House");
  73.                 return;
  74.             }
  75.  
  76.             else if (pair == 2)
  77.             {
  78.                 Console.WriteLine("Two Pairs");
  79.                 return;
  80.             }
  81.             else if (triple == 1 && pair == 0)
  82.             {
  83.                 Console.WriteLine("Three of a Kind");
  84.                 return;
  85.             }
  86.             else if (pair == 1 && triple == 0)
  87.             {
  88.                 Console.WriteLine("One Pair");
  89.                 return;
  90.             }
  91.             for (int k = 1; k < 11; k++)
  92.             {
  93.                 straight = 0;
  94.                 for (int m = 0; m < 5; m++)
  95.                 {
  96.                     if (deck[k + m, 0] == 1)
  97.                     {
  98.                         straight++;
  99.                     }
  100.                 }
  101.                 if (straight == 5)
  102.                 {
  103.                     Console.WriteLine("Straight");
  104.                     return;
  105.                 }
  106.             }
  107.  
  108.             Console.WriteLine("Nothing");
  109.         }
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement