12,501,082 members (44,429 online)
Add your own
alternative version

33.1K views
659 downloads
16 bookmarked
Posted

# Check texas holdem poker hand

, 14 Mar 2007 CPOL
 Rate this:
Please Sign up or sign in to vote.
Check what your poker hand is in a Texas Holdem game

## Introduction

This program tells you what kind of poker hand you have in a Texas Holdem game, given the 7 cards you are allowed to use.

## Background

I was trying to create a program that would check the win percentage in a Texas Holdem game, and the hardest part was finding code to check what type of poker hand you have. So I decided to make a program that would do just that.

## Using the code

I made the code as easy to read as possible.

Their are many comments explaining what each part of the code does.

Some of the code in the function checkHand() is redundant. I wrote it like that to make the function easier to read.

The functions in this program are:

```int main()
void checkPokerHand(int hand[], int card1, int card2);
string checkCard(int card);
string checkSuit(int card);
void sort(int a[]);```

main() Asks for the card and displays the best hand.

checkHand() takes in an array of integers with size 14.

 hand[#] Sent Returned hand[0] 0 Poker hand:8 = Straight Flush7 = Four of a kind6 = Full House5 = Flush4 = Straight3 = Three of a kind2 = Two Pair1 = Pair0 = High Card hand[1] 0 Pair Card:(e.g. four of a kind 2s = 2) Two Pair:high pair hand[2] 0 High card Two Pair:low pair hand[3] 0 Second highest card in hand hand[4] 0 Third highest card in hand hand[5] 0 Fourth highest card in hand hand[6] 0 Lowest card in hand hand[7] card1 Lowest card hand[8] card2 Second lowest card hand[9] card3 Third lowest card hand[10] card4 Fourth highest card hand[11] card5 Third highest card hand[12] card6 Second highest card hand[13] card7 Highest card

card1 is the highest of your two cards.

card 2 is the lowest of your two cards.

checkCard(int card) returns the face value of a card in a string
(e.g. 2 returns "2" - 14 returns "A")

checkSuit(int card) returns the suit of a card in a string
(e.g. 1 returns "Hearts"; 2 returns "Clubs"; 3 returns "Diamonds"; 4 returns "Spades";)

## History

Version 1.0
Checks for the best poker hand when given 7 cards.

## License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

## About the Author

 United States
No Biography provided

## You may also be interested in...

 Pro Pro

## Comments and Discussions

 First Prev Next
 Are you sure about the correctness of this code? sssirf18-Jul-08 2:55 sssirf 18-Jul-08 2:55
 Re: Are you sure about the correctness of this code? c2z232f25-Jul-08 11:47 c2z232f 25-Jul-08 11:47
 Re: Are you sure about the correctness of this code? c2z232f28-Jul-08 22:27 c2z232f 28-Jul-08 22:27
 stdaf.h not include + error Aahzmos14-Aug-07 16:52 Aahzmos 14-Aug-07 16:52
 how does it work ?? klaudioz26-Jun-07 6:31 klaudioz 26-Jun-07 6:31
 Last Visit: 31-Dec-99 18:00     Last Update: 24-Sep-16 17:00 Refresh 1

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 14 Mar 2007
Article Copyright 2007 by UziTech
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid