




已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include #include windows.h#include #include time.h#include assert.h#include conio.husing namespace std;struct eachcasebool havebomb;int state;/if state = 0,means nothing; less then 8 and more then 1 means there are state bomb near here; 9 means you have find here ;/10 means you have point here;class viewfriend int check();public:view(int width,int hight,int numofbomb);void show();eachcase *qipan;int gethight();int getwidth();int getnumbomb();void falseshow();int bombnear(int,int);int check(bool* &,int,int);void flashshow();int check();/ check whether ignite the bomb, if not, check arrond/ return 1 means win ;2 means lose; 0 means nothingview();private:int hight,width,numbomb;public:int nhight,nwidth;int main()bool quit = true;while(quit)std:cout-std:endl;std:cout- welcome -std:endl;std:cout- -std:endl;std:cout- -std:endl;std:cout- w:up s:down a:left d :right p:point b:begin e:enter q:qiut -std:endl;std:cout- -std:endl;std:cout- -std:endl;std:cout- -std:endl;std:cout- -std:endl;std:cout- by uil from scut -std:endl;std:cout-std:endl;char gets = cin.get();if(gets = q)quit = false;continue;else if(gets != b)system(cls);continue;system(cls);int w,h,b;coutplease enter the with:w;if(w1)w=10;coutplease enter the hight:h;if(h1)h=10;coutplease enter the number of bomb:b;if(b1)b=10;view views(h,w,b);clock_t start=clock();clock_t flash = start;bool* forcheck = new bool*h;for(int f = 0; f h;f+)forcheckf = new bool w;for(int r = 0;r 0.5)views.flashshow();sleep(300);views.show();char get;get = _getch();switch(get)case w:if(views.nhight-1=0 )/& views.qipanviews.nhight-1views.nwidth.state%10 = 0)views.nhight-;break;case s:if(views.nhight+1=0)/ & views.qipanviews.nhightviews.nwidth-1.state%10 = 0)views.nwidth-;break;case d:if(views.nwidth+1views.getwidth()/ & views.qipanviews.nhightviews.nwidth+1.state%10 = 0)views.nwidth+;break;case p:end = views.check();break;case r:restart = false;break;/ we need to improve herecase q:quit = false;break;case e:end = views.check(forcheck,views.nhight,views.nwidth);break;default:continue;views.show();/the main circle, which get the importif(end = 1)views.falseshow();coutendlyou are loseendl;coutuse time:(double)(clock() - start)/clocks_per_sec)endl;couta;if(a = n)return 0;else if(a = y)restarts = true;/ need to improve.else if(end = 2)coutendlyou are win!endl;coutuse time:(double)(clock() - start)/clocks_per_sec)endl;couta;bool restarts = false;while(cin & !restarts)char a;cina;if(a = n)return 0;else if(a = y)restarts = true;/ need to improvesystem(cls);return 0;int view:check(bool* &forcheck,int h,int w)forcheckhw = false;if(qipanhw.havebomb)return 1;int wcheck = bombnear(h,w);/ use to deside continue to check;if(wcheck)qipanhw.state= wcheck;elseqipanhw.state = 9;if(h-1 =0 & w-1=0 & forcheckh-1w-1)/ here show the view.qipan here have problemcheck(forcheck,h-1,w-1);if(h-1 = 0 & forcheckh-1w)check(forcheck,h-1,w);if(h-1 =0 & w+1 = 0 & forcheckhw-1)check(forcheck,h,w-1);if(w+1 width & forcheckhw+1)check(forcheck,h,w+1);if(h+1 = 0 & forcheckh+1w-1)check(forcheck,h+1,w-1);if(h+1 hight & forcheckh+1w)check(forcheck,h+1,w);if(h+1 hight & w+1 width & forcheckh+1w+1)check(forcheck,h+1,w+1);return 0;view:view(int hights,int widths,int numofbomb)hight = hights;/width = hights;/numbomb = numofbomb;nhight = 0;nwidth = 0;qipan = new eachcase*hight;/assert(sizeof(qipan)0);srand(time(0);/ we use it to make bombint b = numofbomb;int h = 0;for(;h=hight;h+)qipanh = new eachcasewidth;/assert(sizeof(qipanh)0);for(int w = 0; w = width ; w+)qipanhw.state = 0;qipanhw.havebomb = false;for(int nb = 0; nb = numbomb-1;)int hb=rand()%hight;int wb=rand()%width;if(!qipanhbwb.havebomb)qipanhbwb.havebomb = true;nb+;int view:gethight()return hight;int view:getwidth()return width;int view:getnumbomb()return numbomb;void view:show()system(cls);/qipannhightnwidth.state=9;for(int n=0;n=(width)*4+2;n+)std:cout-;for(int h=0;h=hight-1;h+)std:coutstd:endl|;for(int w=0;w=width-1;w+)int i=0;if(qipanhw.state = 0)std:cout ;else if( 0 qipanhw.state & qipanhw.state 9)std:coutqipanhw.state ; /need to advancedelse if(qipanhw.state = 9)std:cout ;else if(qipanhw.state = 10)std:coutp ;else if(qipanhw.state = 11)std:cout ;elseassert(0);std:cout|std:endl;for(int k=0;k=(width)*4+2;k+)std:cout-;couthight:nhight+1 width:nwidth+1endl;view:view()for(int n=0;n=0 & w-1=0)if(qipanh-1w-1.havebomb)bombs+;if(h-1 =0)if(qipanh-1w.havebomb)bombs+;if(h-1 =0 & w+1 =0)if(qipanhw-1.havebomb)bombs+;if(w+1 width )if(qipanhw+1.havebomb)bombs+;if(h+1 =0)if(qipanh+1w-1.havebomb)bombs+;if(h+1 hight)if(qipanh+1w.havebomb)bombs+;if(h+1 hight & w+1 width )if(qipanh+1w+1.havebomb)bombs+;return bombs;void view:falseshow()system(cls);/qipannhightnwidth.state=9;for(int n=0;n=(width)*4+2;n+)std:cout-;for(int h=0;h=hight-1;h+)std:coutstd:endl|;for(int w=0;w=width-1;w+)int i=0;if(qipanhw.state = 0)if(qipanhw.havebomb)std:cout ;elsestd:cout ;else if( 0 qipanhw.state & qipanhw.state 9)std:coutqipanhw.state ; /need to advancedelse if(qipanhw.state = 9)std:cout ;else if(qipanhw.state = 10)if(qipanhw.havebomb)std:cout ;elsestd:cout ;else if(qipanhw.state = 11)std:cout;elseassert(0);std:cout|std:endl;for(int k=0;k=(width)*4+2;k+)std:cout-;void view:flashshow()system(cls);/qipannhightnwidth.state=9;for(int n=0;n=(width)*4+2;n+)std:cout-;for(int h=0;hhight;h+)std:coutstd:endl|;for(int w=0;wwidth;w+)if( h = nhight & w = nwidth)std:cout ;else if(qipanhw.state = 0)std:cout ;else if( 0 qipanhw.state & qipanhw.state 9)std:coutqipanhw.state ; /need to adva
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 森林里的绅士课件
- 棋类社团招新课件
- 桥梁资料填写范例课件
- 2025年航空业空乘人员面试与笔试题目集及答案
- 2025年主管护师考试试题及答案
- 2025年机械制图高级人才选拔面试题及答案详解
- 2025年乒乓球裁判证考试试题及答案
- 2025年金融投资策略与风险控制培训教程及答案
- 2026届黑龙江省齐齐哈尔市龙江县二中化学高三上期末质量检测试题含解析
- 2025年数据驱动决策数据分析师认证考试全真试题
- 2024版酷家乐课件
- 税务停业申请书
- 班组长一日工作培训
- 2025年春季安全教育主题班会教育记录
- 劳保用品的使用和管理
- 人教版六年级数学下册《全册完整》教案
- 2024年中国VHB泡棉胶带市场调查研究报告
- 7s管理工作汇报
- 金融科技推动新质生产力发展
- 微波集成电路 课件全套 谢小强 第1-6章 绪论 -微波单片集成技术
- 肝脓肿合并糖尿病业务查房
评论
0/150
提交评论