Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the program to \'deal\' two hands of cards (two players). Each player wil

ID: 3653144 • Letter: M

Question

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. Then print out the losing player total points and his cards. I cant get it to work. I get an error when I try to deal cards, the last part of the code. #include #include #include #define NCARDS 52 #define NPROPS 2 #define NSUITS 4 #define NFACES 13 char* suit[NSUITS]={"hearts","spades","clubs","diamonds"}; char* face[NFACES]={"ace","two","three","four","five","six","seven","eight","nine", "ten","jack","queen","king"}; 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]); void dealCards(int deck [NCARDS][NPROPS], int i); int GetPlayValue(int deck[NCARDS][NPROPS], int i); int main() { int deck[NCARDS][NPROPS]; int src; int dest; int i; srand(time(NULL)); printf(" Initializing the deck... "); InitDeck(deck); printf(" Shuffling the deck... "); ShuffleDeck(deck); for (i=0; i<4; suit++) for (face=0; face<13; face++) { deck[row][0]= suit; deck[row][1]= face; row++; } } void ShuffleDeck(int deck[NCARDS][NPROPS]) { int src, dest, i; for (i=0; i 0) && (face < 10)) return face+1; else return 10; } void dealCards(int deck [NCARDS][NPROPS], int i) { int HAND1 [5][2]; int HAND2 [5][2]; int row; row=0; for(i=0;i<5;i++) { HAND1 = deck[row]; row++; HAND2= deck[row]; row++ } }

Explanation / Answer

#include #include #include #include #define MAX 10000 char * multiply(char [],char[]); int main(){ char a[MAX]; char b[MAX]; char *c; int la,lb; int i; printf("Enter the first number : "); scanf("%s",a); printf("Enter the second number : "); scanf("%s",b); printf("Multiplication of two numbers : "); c = multiply(a,b); printf("%s",c); return 0; } char * multiply(char a[],char b[]){ static char mul[MAX]; char c[MAX]; char temp[MAX]; int la,lb; int i,j,k=0,x=0,y; long int r=0; long sum = 0; la=strlen(a)-1; lb=strlen(b)-1; for(i=0;i=0;j--){ temp[k++] = (b[i]*a[j] + r)%10; r = (b[i]*a[j]+r)/10; } temp[k++] = r; x++; for(y = 0;y
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote