免费预览已结束,剩余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 ; /nee
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 鼠害防治技术实施方案
- 九年级化学知识点归纳总结手册
- 建筑岗位劳动防护用品管理细则范本
- 科凡定制活动方案
- 智能家居维修成本分析-洞察及研究
- 强阳保肾丸市场拓展策略-洞察及研究
- 耐电弧涂层材料探索-洞察及研究
- 融合技术在物联网-洞察及研究
- 证券经纪业务的数字化转型技术选型-洞察及研究
- 酒吧O2O用户行为分析-洞察及研究
- 2025江苏苏州市姑苏区劳动人事争议仲裁院协理员招聘5人考试参考题库及答案解析
- 国家开放大学:《政治学原理》题库及答案
- 2023年贵州省建筑工程施工许可管理实施细则
- 光伏监控系统
- 血透室规章制度及
- 《律师承办行政案件规范》-推荐
- GB/T 531.1-2008硫化橡胶或热塑性橡胶压入硬度试验方法第1部分:邵氏硬度计法(邵尔硬度)
- GB/T 21563-2018轨道交通机车车辆设备冲击和振动试验
- 肺癌教学查房演示教学课件
- 2019年全国卷2(物理)含答案
- 机电设备装调与维护技术(第2版)全册电子教案
评论
0/150
提交评论