The program imitates a gambling card game. The program shows you three cards, then the program interchange them, and if you can guess correctly where a particular card is, you win.
Here is some sample interaction with the program:
Card 1 is the 7 of clubs
Card 2 is the jack of hearts
Card 3 is the ace of spades
I’m swapping card 1 and card 3
I’m swapping card 2 and card 3
I’m swapping card 1 and card 2
Now, where (1, 2, or 3) is the ace of spades?
If the user insert 3
The program will print” sorry, you lose.”
Solution hints:
Implement the previous program using structure, this structure represent the data of Card (number and suit), so the structure uses separate members to hold of the number of the card and suit. The number runs from 2 to 14, where 11, 12, 13 and 14 represent the jack, queen, king, and ace, respectively. The suit runs from 0 to 3, where these four numbers represent clubs, diamonds, hearts, and spades.