C编写的“扫雷”源程序

C编写的“扫雷”源程序

ID:43324066

大小:99.00 KB

页数:9页

时间:2019-09-30

C编写的“扫雷”源程序_第1页
C编写的“扫雷”源程序_第2页
C编写的“扫雷”源程序_第3页
C编写的“扫雷”源程序_第4页
C编写的“扫雷”源程序_第5页
资源描述:

《C编写的“扫雷”源程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、//headerfile#include#inelude#inelude#inelude#ineludevconio.h>//defines#defineKEY_UP0xE048#defineKEY_DOWN0xE050#defineKEY_LEFT0xE04B#defineKEY_RIGHT0xE04D#defineKEY_ESCOxOOlB#defineKEY_1*1'#defineKEY_22#defineKEY_33#defineGAMEMAXWIDTH100#defineGAME_MA

2、X_HEIGHT100//StringsResource#defineSTR_GAMETITLEHArrowKey:MoveCursorKeyl:OpenKey2:MarkKey3:OpenNeighborsH#defineSTR_GAMEWIN"Congratulations!YouWin!Thankyouforplaying!"#defineSTR_GAMEOVER"GameOver,thankyouforplaying!"#defineSTR_GAMEEND"Presentedbyyzfy.PressESCtoexit"////Baseclassc

3、lassCConsoleWnd{public:staticintTextOut(constchar*);staticintGotoXY(intzint);staticintCharOut(int,int,constint);staticintTextOutfint,int,constchar*);staticintGetKey();public:};//{{//classCConsoleWnd////intCConsoleWnd::GetKey()//WaitforstandardinputandreturntheKeyCode//intCConsoleWnd::Ge

4、tKey()intnkey=getch(),nk=O;if(nkey>=12811nkey==O)nk=getch();returnnk>0?nkey*256+nk:nkey;}////intCConsoleWnd::GotoXY(intx,inty)//Movecursorto(x,y)//OnlyConsoleApplication//intCConsoleWnd::GotoXY(intx,inty){COORDcd;cd.X=x;cd.Y=y;returnSetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDL

5、E),cd);}////intCConsoleWnd::TextOut(constchar*pstr)//Outputastringatcurrentposition//intCConsoleWnd::TextOut(constchar*pstr){for(;*pstr;++pstr)putchar(*pstr);return0;}////intCConsoleWnd::CharOut(intx,inty,constintpstr)//Outputacharat(x,y)//intCConsoleWnd::CharOut(intx,inty,constintpstr)

6、{GotoXY(x,y);returnputchar(pstr);}////intCConsoleWnd::TextOut(constchar*pstr)//Outputastringat(x,y)//intCConsoleWnd::TextOut(intx,inty,constchar*pstr){GotoXY(x,y);returnTextOut(pstr);}//}}////ApplicationclassclassCSLGame:publicCConsoleWndprivate:private:intcurX,curY;intpoolWidth,poolHei

7、ght;intbm_gamepool[GAME_MAX_HEIGHT+2][GAME_MAX_WIDTH+2];public:CSLGame():curX(0)zcurY(0){poolWidth=poolHeight=0;}intlnitPool(int,int,int);intMoveCursor(){returnCConsoleWnd::GotoXY(curX,curY);}intDrawPool(int);intWaitMessagef);intGetShowNum(int,int);intTryOpen(int,int);private:i

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。