Question: Please post the solution and output. Please save the program with the name 'cards.c'. a) Write a structure (struct card) that will represent a card

Please post the solution and output. Please save the program with the name 'cards.c'.

a) Write a structure (struct card) that will represent a card in a standard deck of playing cards. You will need to represent both the suit (clubs, diamonds, hearts or spades) as well as rank (K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2, A) of each card. Note that a deck of playing cards can be represented as an array declared as

struct card deck[52];

b) Write a function that will perform a perfect shuffle on a deck of cards represented using data structures from part a. In a perfect shuffle, the deck is broken exactly in half and rearranged so that the first card is followed by the 27th card, followed by the second card, followed by the 28th card, and so on.

c) Write a program that tests how many perfect shuffles are necessary to return the deck to its original configuration.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!