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 isNeed help with this homework. I already started the majority however the

and if you wanna copy:

#include #include #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 ile onmal Vew Help 4include 4include 4include tine.h> define NCARDS 52 deine NPROPS 2 ldefine NSUITS 4 idefine NTACCS 13 / card text values using array of pointers to preinitialized constant text strings char suit NSUITS l"hearts","spades","clubs,dimonds char facel NENCES]-"aceto""three","four","ive","six", seven "eight,"nine", "ten, jack","queen, "king function prototypes used for manipulating cards void printcard(int deckINLARUSNPRursj, int i); void smaptard(nt deck[NLAHUSILNPHUPSJ, int sre, int dest)i void shuftleveck(int deck NLARU'S] LNPHUPS int GetPlayvalue(int deukINLARUS] [NU int i); irl nainO Fueck uf cards face, suile, caru value inL duck[NCARDS] [NPRDS] inet rawtime-tine(NULL) int i; srand tinc L) init the deck loap an the chards TnitDrck(dock); Shiuffloock(dork); prinL Lhe detk puls("the for (i-e; shuffled deck is;"); CHCARDS ; tt) Prnici rul(deck, i) ; printf printed ons"ctin(&ratime)); systen PAUISE") return 0; void TnitDrck int drck[NCARDS] [NPROS]) int suit,face,card; card-a for (suit-; suitNSLITTS; suit) for(fac facNFACFS; fac) derk[card uit; derk[card fare; card++ void Printcard int deck[NCARSHPCPS int card) int terpface,tenpsuit; tempface deck card11 tempsuit deck card] [e]. //printf{"Cand %d of Sult %d has face %d " ,cara, tempsuit ,tenp face); printt("Card %d ot suit Xs has face %s ", card, suit! tempsuitj, face Iterpfacel); void Shuffleeck(int deckINCARDS JLNPROPS J) Int card,dest,srei tor (card-e; cardKAHDS cardtt) dest- INCARUS-1-card; tcardval-drcksrc][i]; dirck[src][i]- teardval

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!