ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:16.37KB ,
资源ID:6497822      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6497822.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(最新扫雷代码C++.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

最新扫雷代码C++.docx

1、最新扫雷代码C+#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 h

2、ere;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 arr

3、ond/ 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:en

4、ter 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

5、;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();ch

6、ar 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.nh

7、ightviews.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 import

8、if(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 rest

9、arts = 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)qipan

10、hw.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(

11、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

12、= 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()%hi

13、ght;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:

14、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:

15、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

16、-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+)in

17、t 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;el

18、seassert(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:co

19、ut ;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:nwidt

20、h+1endl;int view:check()if(qipannhightnwidth.state = 0)qipannhightnwidth.state = 10;else if(qipannhightnwidth.state = 10)qipannhightnwidth.state = 0;int finded=0;for(int hs=0;hs = hight;hs+)for(int ws=0;ws = width;ws+)if(qipanhsws.state = 10 /*| qipanhsws.state = 0*/ & qipanhsws.havebomb)finded+;/ check where find all bombif(finded = numbomb) /error/return 2;return 0;公益活动策划方案

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1