You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue in the solution for Project 3 of Chapter 10:
In the following code chunk from the solution, after reading a three-of-a-kind, the loop reads it again from the second card and sees a pair. The program thus detects a full house.
int matches = 0;
for (int i = 0; i < NUM_CARDS; i++) {
matches = 0;
for (int j = i + 1; j < NUM_CARDS; j++) {
if (hand[j][0] == hand[i][0])
matches++;
}
if (matches == 1) pairs++;
if (matches == 2) three = true;
if (matches == 3) four = true;
}
/* check for 4-of-a-kind, 3-of-a-kind, and pairs by
looking for "runs" of cards with identical ranks */
card = 0;
while (card < NUM_CARDS) {
rank = hand[card][RANK];
run = 0;
do {
run++;
card++;
} while (card < NUM_CARDS && hand[card][RANK] == rank);
switch (run) {
case 2: pairs++; break;
case 3: three = true; break;
case 4: four = true; break;
}
}
The text was updated successfully, but these errors were encountered:
Issue in the solution for Project 3 of Chapter 10:
In the following code chunk from the solution, after reading a three-of-a-kind, the loop reads it again from the second card and sees a pair. The program thus detects a full house.
Here's a working solution. The following code chunk is from KNKing's online solutions for select exercises (http://knking.com/books/c2/answers/c10.html):
The text was updated successfully, but these errors were encountered: