21点游戏编程.doc
上传人:qw****27 上传时间:2024-09-12 格式:DOC 页数:10 大小:49KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

21点游戏编程.doc

21点游戏编程.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

/*Filename:BLAKJACK.CThisprogramplaysagameofBlackjackwithyou.Thecomputeristhedealerandyouarethevictim-er,Imeanplayer.Thedealergetsacardthatyoucansee.Thedealerthenasksifyouwantanothercardbyasking“Hit”or“Stand.”Ifyouchoosetohit,thedealergivesyouanothercard.Ifyouchoosetostand,thedealerdrawsorstands,andthegameisplayedoutaccordingtothecardsyouandthedealerhave.AswithrealBlackjack,thedealerstandson17.Thewinnerisannouncedonlyafterboththeplayer’sandthedealer’shandsarefinished.*//******************************************************ANSICstandardheaderfilesappearnext*/#include<stdio.h>#include<time.h>#include<ctype.h>#include<stdlib.h>/******************************************************Definedconstantsappearnext*/#defineBELL‘\a’#defineDEALER0#definePLAYER1/*Mustkeeptwosetsoftotalsfordealerandforplayer.ThefirstsetcountsAcesas1andthesecondcountsAcesas11.Unlike“realworld”Blackjack,thisprogramdoesn’tallowsomeAcestobe1whileothersAcesare11inthesamehand.*/#defineACELOW0#defineACEHIGH1/*Onlyoneglobalvariableisusedinthisentireprogram.Thevariableholds0,whichmeansfalseinitially.OncetheuserentershisorhernameininitCardsScreen(),thisvariableissetto1(fortrue),sothenameisneveraskedforagaintherestoftheprogram.*//******************************************************Thisprogram’sspecificprototypes*/voiddispTitle(void);voidinitCardsScreen(intcards[52],intplayerPoints[2],intdealerPoints[2],inttotal[2],int*numCards);intdealCard(int*numCards,intcards[52]);voiddispCard(intcardDrawn,intpoints[2]);voidtotalIt(intpoints[2],inttotal[2],intwho);voiddealerGetsCard(int*numCards,intcards[52],intdealerPoints[2]);chargetans(charmesg[]);voidfindWinner(inttotal[2]);/******************************************************C’sprogramexecutionalwaysbeginsatmain()here*/Main(){intnumCards;/*Equals52atbeginningofeachgame*/intcards[52],playerPoints[2],dealerPoints[2],total[2];charans;/*Foruser’sHit/StandorYes/Noresponse*/do{initCardsScreen(cards,playerPoints,dealerPoints