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 "D": 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; } } } }
Standard input is empty
Standard output is empty
Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: String at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 at Poker.Main () [0x00090] in <f5d93c744bec4adfadbf9d21c5be9670>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null. Parameter name: String at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 at Poker.Main () [0x00090] in <f5d93c744bec4adfadbf9d21c5be9670>:0