### Pocker

This program analyzes a hand of a simplified version of poker. It’s simplified because there are only 4 cards in a hand, there are no face cards, there are no suits, and we don’t care about straights.
We input 4 cards with prompt, each of which must be an unsigned in the range [1,10]. (If input failure or card out of range, complain and die). Output the kind of hand, which will be one of
4 of a kind (for instance, 7 7 7 7)
3 of a kind (for instance, 10 10 1 10)
2 pair (for instance, 8 2 8 2)
1 pair (for instance, 8 1 10 1)
nothing (for instance, 3 1 7 4)

 ``123456789101112131415161718192021`` `````` if ( (w <= 1 && w >= 10) || (x <= 1 && x >= 10) || (y <= 1 && y >= 10 ) || (z <= 1 && z >= 10) ) { switch ( (w==x) + (w==y) + (w==z) + (x==y) + (x==z) + (y==z) ) case 0 : cout <<"Nothing" << endl; break; case 1 : cout <<"1 Pair" <
Do you have a question?
Yes, I am not quite sure how does this line work
`(w==x) + (w==y) + (w==z) + (x==y) + (x==z) + (y==z) )`

and also the whole code is not working
It looks like the four cards are represented by variables w, z, y, z.

Each expression of the form (a==b) is a comparison that evaluates to 1 or 0. So I image that the intent is to identify the number of matching cards, as the sum of these individual expressions is the number of matches. But I haven't bothered to check that this is correct.
 ``123456789101112131415161718192021222324252627`` `````` if ( (w >= 1 && w <= 10) || (x >= 1 && x <= 10) || (y >= 1 && y <= 10 ) || (z >= 1 && z <= 10) ) { switch ( (w==x) + (w==y) + (w==z) + (x==y) + (x==z) + (y==z) ) { case 0: cout <<"Nothing" << endl; break; case 1: cout <<"1 Pair" <

I just fixed it !

also I guess last case should be 6 and instead of the || operator it should be &&
Last edited on
Topic archived. No new replies allowed.