Advertisement
dimipan80

Exam 9. Poker Straight

Jun 24th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. namespace _4.PokerStraight
  2. {
  3.     using System;
  4.  
  5.     public class PokerStraight
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             checked
  10.             {
  11.                 long targetW = long.Parse(Console.ReadLine());
  12.  
  13.                 int countHands = 0;
  14.                 for (int f1 = 1; f1 < 11; f1++)
  15.                 {
  16.                     for (int s1 = 1; s1 <= 4; s1++)
  17.                     {
  18.                         int f2 = f1 + 1;
  19.                         for (int s2 = 1; s2 <= 4; s2++)
  20.                         {
  21.                             int f3 = f2 + 1;
  22.                             for (int s3 = 1; s3 <= 4; s3++)
  23.                             {
  24.                                 int f4 = f3 + 1;
  25.                                 for (int s4 = 1; s4 <= 4; s4++)
  26.                                 {
  27.                                     int f5 = f4 + 1;
  28.                                     for (int s5 = 1; s5 <= 4; s5++)
  29.                                     {
  30.                                         long currentWeight =
  31.                                             ((f1 * 10) + s1) + ((f2 * 20) + s2) + ((f3 * 30) + s3) + ((f4 * 40) + s4) + ((f5 * 50) + s5);
  32.                                         if (currentWeight == targetW)
  33.                                         {
  34.                                             countHands++;
  35.                                         }
  36.                                     }
  37.                                 }
  38.                             }
  39.                         }
  40.                     }
  41.                 }
  42.  
  43.                 Console.WriteLine(countHands);
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement