How would I go about printing every possible 5 card poker hand. I know I need a few for loops but I don't understand how I would go about doing it. Thanks in advance!
How would I go about printing every possible 5 card poker hand. I know I need a few for loops but I don't understand how I would go about doing it. Thanks in advance!
you realise that there are 2598960 dealable hands in poker?
I guess you might make a numerical assignment to every card
and store that list (so that eases dealing with suits) as a start.
No No's:
fflush (stdin); gets (); void main ();
Goodies:
Example of fgets (); The FAQ, C/C++ Reference
My Gear:
OS - Windows XP
IDE - MS Visual C++ 2008 Express Edition
ASCII stupid question, get a stupid ANSI
OK what if I didn't want to print them out but I just wanted to go through every possible hand and then do something with it later.
If you really want to do it you can try something like this:
1) assign a unique value to each card in the deck ranging from 0 to 51.
2) declare a series of nested loops, one loop for each card in a hand---5 cards per hand means 5 nested loops, 7 cards per hand means 7 nested loops. Lets say there are 5 cards per hand.
3) Then the outer most loop ranges for 0 to 47 and is called a. The next loop ranges from a + 1 to 48 and is called b. The next loop ranges from b + 1 to 49 and is called c. And so on.
4) The value of card[0] in any given hand will be a,
the value of card[1] in any given hand will be b,
the value of card[2] in any given hand will be c,
etc.
5) Use the value of any given card to refer back to its face and suit value if you want instead to display that information instead of the numerical value.
6) Do what you will with any given hand
7) Generate the next hand until all hands have be generated.
Other than the academics of giggling all the variable values to generate all the permutations this seems relatively pointless though.
Last edited by elad; 05-19-2006 at 01:59 PM.
You're only born perfect.