Hello, I hope someone can help me out. I am going to be taking the
third step in a programming class soon(I took the previous two a while
ago at a different school) and in an effort to get back up to speed, I
bought the Dietel book How To Program 5th ed. I am going through some
examples trying to work them out, and have been doing pretty good, but
came across one exercise that has me stumped. It's a card shuffling
program that deals 5 cards, and stores the face value and suit in
arrays respectively. I have pasted the code which I hope shows that.
// to deal only 5 cards for a poker hand
for ( int card = 1; card <= 5; card++ )
{
// loop through rows of deck
for ( int row = 0; row <= 3; row++ )
{
// loop through columns of deck for current row
for ( int column = 0; column <= 12; column++ )
{
// if slot contains current card, display card
if ( deck[ row ][ column ] == card )
{
cout << setw( 5 ) << right << face[ column ]
<< " of " << setw( 8 ) << left << suit[ row ]
<< ( card % 2 == 0 ? '\n' : '\t' );
} // end if
} // end innermost for
} // end inner for
} // end outer for
What this example asks to do is to modify the program so that it can
determine if the hand has a pair. (and three of a kind and so on)
Considering the "cards" are stored in arrays, how would you compare all
5 face values for example and be able to tell their are two of a kind?
Thanks for taking the time to look at this and any help you can
provide.
Chaz