Question
Need help with this homework. I already started the majority however the last part i cannot figure out how to do. the objetive is: Take
Need help with this homework. I already started the majority however the last part i cannot figure out how to do. the objetive is: Take the program written last weekend that creates a deck of cards, shuffles them, and then lists them out. Modify the program to 'deal' two hands of cards (two players). Each player will be dealt 5 cards. Deal one to the first player, then one to second player. Repeat until both players have 5 cards in their hand. Then compute the total points in each player's hand and determine the winner with the most points. If a player has an ace, then count that as 11 points. Print out the winning player total points and then his cards.
My code is
and if you wanna copy:
#include
#define NCARDS 52 #define NPROPS 2
#define NSUITS 4 #define NFACES 13
// card text values using array of pointers to preinitialized constant text strings char* suit[NSUITS]={"hearts","spades","clubs","diamonds"};
char* face[NFACES]={"ace","two","three","four","five","six","seven","eight","nine", "ten","jack","queen","king"};
// function prototypes used for manipulating cards void PrintCard(int deck[NCARDS][NPROPS], int i); void InitDeck(int deck[NCARDS][NPROPS]); void SwapCards(int deck[NCARDS][NPROPS], int src, int dest); void ShuffleDeck(int deck[NCARDS][NPROPS]); int GetPlayValue(int deck[NCARDS][NPROPS], int i);
int main() {
//deck of cards // face, suite, card value int deck[NCARDS][NPROPS]; time_t rawtime=time(NULL);
int i;
srand(time(NULL)); // init the deck // loop on the chards InitDeck(deck); ShuffleDeck(deck);
// print the deck puts("The shuffled deck is:"); for (i=0; i printf("Printed on %s",ctime(&rawtime)); system("PAUSE"); return 0; } void InitDeck(int deck[NCARDS][NPROPS]) { int suit,face,card; card=0; for (suit=0; suit } } void PrintCard(int deck[NCARDS][NPROPS], int card) { int tempface,tempsuit; tempface = deck[card][1]; tempsuit = deck[card][0]; //printf("Card %d of Suit %d has face %d " ,card,tempsuit,tempface); printf("Card %d of suit %s has face %s ", card, suit[tempsuit], face [tempface]); } void ShuffleDeck(int deck[NCARDS][NPROPS]) { int card,dest,src; for (card=0; card } } void SwapCards(int deck[NCARDS][NPROPS], int src, int dest) { int tcardVal,i; for(i=0;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started