Advertisement
4valeri

Gambling EDIT

Feb 7th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class Gambling
  9. {
  10.     static void Main(string[] args)
  11.     {
  12.         int cash = int.Parse(Console.ReadLine());
  13.         int potAmount = cash * 2;
  14.  
  15.         string[] housesHand = Console.ReadLine().Split(' ');
  16.         //int card1 = int.Parse(housesHand[0]);
  17.         //int card2 = int.Parse(housesHand[1]);
  18.         //int card3 = int.Parse(housesHand[2]);
  19.         //int card4 = int.Parse(housesHand[3]);
  20.  
  21.         int allCards = 0;
  22.  
  23.         for (int i = 0; i < housesHand.Length; i++)
  24.         {
  25.             switch (housesHand[i])
  26.             {
  27.                 case "J":
  28.                     allCards += 11;
  29.                     break;
  30.                 case "Q":
  31.                     allCards += 12;
  32.                     break;
  33.                 case "K":
  34.                     allCards += 13;
  35.                     break;
  36.                 case "A":
  37.                     allCards += 14;
  38.                     break;
  39.                 default:
  40.                     allCards += int.Parse(housesHand[i]);
  41.                     break;
  42.             }
  43.         }
  44.  
  45.         int allPossibleCombinations = 0;
  46.         int myWinningCombinations = 0;
  47.  
  48.         for (int card1 = 2; card1 <= 14; card1++)
  49.         {
  50.             for (int card2 = 2; card2 <= 14; card2++)
  51.             {
  52.                 for (int card3 = 2; card3 <= 14; card3++)
  53.                 {
  54.                     for (int card4 = 2; card4 <= 14; card4++)
  55.                     {
  56.                         allPossibleCombinations++;
  57.  
  58.                         int currecntPoints = card1 + card2 + card3 + card4;
  59.  
  60.                         if (currecntPoints > allCards)
  61.                         {
  62.                             myWinningCombinations++;
  63.                         }
  64.                     }
  65.                 }
  66.             }
  67.         }
  68.         Console.WriteLine(myWinningCombinations);
  69.         Console.WriteLine(allPossibleCombinations);
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement