Question
C++ program In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way: High
C++ program
In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:
High Card: Highest value card.
One Pair: Two cards of the same value.
Two Pairs: Two different pairs.
Three of a Kind: Three cards of the same value.
Straight: All cards are consecutive values.
Flush: All cards of the same suit.
Full House: Three of a kind and a pair.
Four of a Kind: Four cards of the same value.
Straight Flush: All cards are consecutive values of same suit.
Royal Flush: Ten, Jack, Queen, King, Ace, in same suit.
The cards are valued in the order:
2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
If two players have the same ranked hands then the rank made up of the highest value wins; for example, a pair of eights beats a pair of fives (see example 1 below). But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on. Consider the following five hands dealt to two players:
The given file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. Assume that all hands are valid (no invalid characters or repeated cards), each player's hand is in no specific order, and in each hand there is a clear winner.
How many hands does Player 1 win?
----------------------------------------------------------------------------
poker.txt
8C TS KC 9H 4S 7D 2S 5D 3S AC
5C AD 5D AC 9C 7C 5H 8D TD KS
3H 7H 6S KC JS QH TD JC 2D 8S
TH 8H 5C QS TC 9H 4D JC KS JS
7C 5H KC QH JD AS KH 4C AD 4S
5H KS 9C 7D 9H 8D 3S 5D 5C AH
6H 4H 5C 3H 2H 3S QH 5S 6S AS
TD 8C 4H 7C TC KC 4C 3H 7S KS
Hand Player Player 2 Winner 1 l 5H 5C 6S 7S KD 2C3S SS SD TD Player 2 Pair of Fives Pair of Eights 2 5D 8C OS JS AC 2C 5C 7D SS QH Player 1 Highest card Ace Highest card Queen 3 2D 9C AS AH AC 3D 6D 7D TD QD Player 2 Three Aces Flush with Diamonds 4 4D 6S 9H QH QC 3D 6D 7H QD QS Player 1 Pair of Queens Pair of Queens Highest card Nine Highest card Seven 5 2H 2D 4C 4D 4S 3C 3D 3S 9S 9D Player 1 Full House Full House With Three Fours with Three Threes Hand Player Player 2 Winner 1 l 5H 5C 6S 7S KD 2C3S SS SD TD Player 2 Pair of Fives Pair of Eights 2 5D 8C OS JS AC 2C 5C 7D SS QH Player 1 Highest card Ace Highest card Queen 3 2D 9C AS AH AC 3D 6D 7D TD QD Player 2 Three Aces Flush with Diamonds 4 4D 6S 9H QH QC 3D 6D 7H QD QS Player 1 Pair of Queens Pair of Queens Highest card Nine Highest card Seven 5 2H 2D 4C 4D 4S 3C 3D 3S 9S 9D Player 1 Full House Full House With Three Fours with Three ThreesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started