View Code
. dispCard( cardDrawn, points[. dispCard( cardDrawn, points[. . (): printf(,. points[ACELOW] += . points[ACEHIGH] += . . (): printf(,. points[ACELOW] += . points[ACEHIGH] += . . (): printf(,. points[ACELOW] += . points[ACEHIGH] += . . : points[ACELOW] +=. (cardDrawn==. printf(,. points[ACEHIGH]+= . . points[ACEHIGH]+=. printf(. . }
void dispCard(int cardDrawn,int points[]); void dispCard(int cardDrawn, int points[]) { switch(cardDrawn) { case 11: puts("Jack"); points[ACELOW] += 10; points[ACEHIGH] += 10; break; case 12: puts("Queen"); points[ACELOW] += 10; points[ACEHIGH] += 10; break; case 13: puts("King"); points[ACELOW] += 10; points[ACEHIGH] += 10; break; case 1 :puts("Ace"); points[ACELOW] += 1 ; points[ACEHIGH] += 11; break; default :printf("%d\n",cardDrawn); points[ACELOW] += cardDrawn; points[ACEHIGH] += cardDrawn; break; } }
void dispCard(int cardDrawn); void dispCard(int cardDrawn) { switch(cardDrawn) { case 11: puts("Jack"); break; case 12: puts("Queen"); break; case 13: puts("King"); break; case 1 :puts("Ace"); break; default :printf("%d\n",cardDrawn); break; } } void update(int cardDrawn,int points[]); void update(int cardDrawn, int points[]) { switch(cardDrawn) { case 11: case 12: case 13: points[ACELOW] += 10; points[ACEHIGH] += 10; break; case 1 :points[ACELOW] += 1 ; points[ACEHIGH] += 11; break; default :points[ACELOW] += cardDrawn; points[ACEHIGH] += cardDrawn; break; } }
. playerGetsCard(&. playerGetsCard(&numCards,cards,playerPoints);
. playerGetsCard( *numCards, cards[. playerPoints[. playerGetsCard( *numCards, cards[], playerPoints[. . newCard =. printf(. }
. printf();
. printf();
int main(void) { /*……*/ do{ /*……*/ printf("The dealer draws:"); dispCard ( dealCard( numCards , cards ) , dealerPoints ) ; printf("You draw:"); dispCard ( dealCard( numCards , cards ) , playerPoints) ; /*……*/ } while( getAns("\nPlay again(Y/N)?") == 'Y' ); /*詢問是否繼續*/ return 0; }
. . ans = getAns(. ( ans == . playerGetsCard(&. ( ans != );
do { char ans; ans = getAns("Hit or stand (H/S)?"); if ( ans == 'H' ) playerGetsCard(&numCards,cards,playerPoints); if ( ans == ' S ' ) break; } while( 1 );