扫雷代码计算机C++Word下载.docx

上传人:b****1 文档编号:1402590 上传时间:2023-04-30 格式:DOCX 页数:20 大小:16.77KB
下载 相关 举报
扫雷代码计算机C++Word下载.docx_第1页
第1页 / 共20页
扫雷代码计算机C++Word下载.docx_第2页
第2页 / 共20页
扫雷代码计算机C++Word下载.docx_第3页
第3页 / 共20页
扫雷代码计算机C++Word下载.docx_第4页
第4页 / 共20页
扫雷代码计算机C++Word下载.docx_第5页
第5页 / 共20页
扫雷代码计算机C++Word下载.docx_第6页
第6页 / 共20页
扫雷代码计算机C++Word下载.docx_第7页
第7页 / 共20页
扫雷代码计算机C++Word下载.docx_第8页
第8页 / 共20页
扫雷代码计算机C++Word下载.docx_第9页
第9页 / 共20页
扫雷代码计算机C++Word下载.docx_第10页
第10页 / 共20页
扫雷代码计算机C++Word下载.docx_第11页
第11页 / 共20页
扫雷代码计算机C++Word下载.docx_第12页
第12页 / 共20页
扫雷代码计算机C++Word下载.docx_第13页
第13页 / 共20页
扫雷代码计算机C++Word下载.docx_第14页
第14页 / 共20页
扫雷代码计算机C++Word下载.docx_第15页
第15页 / 共20页
扫雷代码计算机C++Word下载.docx_第16页
第16页 / 共20页
扫雷代码计算机C++Word下载.docx_第17页
第17页 / 共20页
扫雷代码计算机C++Word下载.docx_第18页
第18页 / 共20页
扫雷代码计算机C++Word下载.docx_第19页
第19页 / 共20页
扫雷代码计算机C++Word下载.docx_第20页
第20页 / 共20页
亲,该文档总共20页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

扫雷代码计算机C++Word下载.docx

《扫雷代码计算机C++Word下载.docx》由会员分享,可在线阅读,更多相关《扫雷代码计算机C++Word下载.docx(20页珍藏版)》请在冰点文库上搜索。

扫雷代码计算机C++Word下载.docx

//checkwhetherignitethebomb,ifnot,checkarrond

//return1meanswin;

2meanslose;

0meansnothing

~view();

private:

inthight,width,numbomb;

intnhight,nwidth;

intmain()

boolquit=true;

while(quit)

{

std:

:

cout<

<

"

----------------------------------------------------------------"

std:

endl;

-welcome-"

--"

-w:

ups:

downa:

leftd:

rightp:

pointb:

begine:

enterq:

qiut-"

--"

-byuilfromscut-"

chargets=cin.get();

if(gets=='

q'

quit=false;

continue;

}

elseif(gets!

='

b'

system("

cls"

);

intw,h,b;

cout<

pleaseenterthewith:

cin>

>

w;

if(w<

1)

w=10;

pleaseenterthehight:

h;

if(h<

h=10;

pleaseenterthenumberofbomb:

b;

if(b<

b=10;

viewviews(h,w,b);

clock_tstart=clock();

clock_tflash=start;

bool**forcheck=newbool*[h];

for(intf=0;

f<

h;

f++)

forcheck[f]=newbool[w];

for(intr=0;

r<

w;

r++)

forcheck[f][r]=true;

//makeitforcheck()tocheckwhetheracasehavebeenfind

intend=0;

//desidewhetherstop

boolrestart=true;

while(cin&

&

!

end&

restart&

quit)

if((double)((clock()-flash)/clocks_per_sec)>

0.5)

views.flashshow();

sleep(300);

views.show();

charget;

get=_getch();

switch(get)

case'

w'

if(views.nhight-1>

=0)//&

views.qipan[views.nhight-1][views.nwidth].state%10==0)

{

views.nhight--;

break;

s'

if(views.nhight+1<

views.gethight())//&

views.qipan[views.nhight+1][views.nwidth].state%10==0)

views.nhight++;

a'

if(views.nwidth-1>

=0)//&

views.qipan[views.nhight][views.nwidth-1].state%10==0)

views.nwidth--;

d'

if(views.nwidth+1<

views.getwidth())//&

views.qipan[views.nhight][views.nwidth+1].state%10==0)

views.nwidth++;

break;

p'

end=views.check();

r'

restart=false;

//weneedtoimprovehere

e'

end=views.check(forcheck,views.nhight,views.nwidth);

default:

//themaincircle,whichgettheimport

if(end==1)

views.falseshow();

endl<

youarelose"

usetime:

(double)((clock()-start)/clocks_per_sec)<

tryagain?

y/n"

;

boolrestarts=false;

while(cin&

!

restarts)

chara;

a;

if(a=='

n'

return0;

elseif(a=='

y'

restarts=true;

}//needtoimprove.

elseif(end==2)

youarewin!

}//needtoimprove

}

intview:

check(bool**&

forcheck,inth,intw)

forcheck[h][w]=false;

if(qipan[h][w].havebomb)

return1;

intwcheck=bombnear(h,w);

//usetodesidecontinuetocheck;

if(wcheck)

qipan[h][w].state=wcheck;

else

qipan[h][w].state=9;

if(h-1>

=0&

w-1>

forcheck[h-1][w-1])

//hereshowtheview.qipan[][]herehaveproblem

check(forcheck,h-1,w-1);

=0&

forcheck[h-1][w])

check(forcheck,h-1,w);

w+1<

width&

forcheck[h-1][w+1])

check(forcheck,h-1,w+1);

if(w-1>

forcheck[h][w-1])

check(forcheck,h,w-1);

if(w+1<

forcheck[h][w+1])

check(forcheck,h,w+1);

if(h+1<

hight&

w-1>

forcheck[h+1][w-1])

check(forcheck,h+1,w-1);

if(h+1<

forcheck[h+1][w])

check(forcheck,h+1,w);

forcheck[h+1][w+1])

check(forcheck,h+1,w+1);

view:

view(inthights,intwidths,intnumofbomb)

hight=hights;

////////////////

width=hights;

///////////////

numbomb=numofbomb;

nhight=0;

nwidth=0;

qipan=neweachcase*[hight];

//assert(sizeof(qipan)<

0);

srand(time(0));

//weuseittomakebomb

intb=numofbomb;

inth=0;

for(;

h<

=hight;

h++)

qipan[h]=neweachcase[width];

//assert(sizeof(qipan[h])<

for(intw=0;

w<

=width;

w++)

qipan[h][w].state=0;

qipan[h][w].havebomb=false;

for(intnb=0;

nb<

=numbomb-1;

inthb=rand()%hight;

intwb=rand()%width;

if(!

qipan[hb][wb].havebomb)

qipan[hb][wb].havebomb=true;

nb++;

gethight()

returnhight;

getwidth()

returnwidth;

getnumbomb()

returnnumbomb;

voidview:

show()

//qipan[nhight][nwidth].state=9;

for(intn=0;

n<

=(width)*4+2;

n++)

'

-'

for(inth=0;

=hight-1;

|'

for(intw=0;

w<

=width-1;

w++)

inti=0;

if(qipan[h][w].state==0)

■"

elseif(0<

qipan[h][w].state&

qipan[h][w].state<

9)

qipan[h][w].state<

"

//needtoadvanced

elseif(qipan[h][w].state==9)

·

elseif(qipan[h][w].state==10)

p"

elseif(qipan[h][w].state==11)

□"

else

assert(0);

for(intk=0;

k<

k++)

hight:

nhight+1<

width:

nwidth+1<

~view()

deleteqipan[n];

deleteqipan;

bombnear(inth,intw)

intbombs=0;

=0)

if(qipan[h-1][w-1].havebomb)

bombs++;

if(qipan[h-1][w].havebomb)

width)

if(qipan[h-1][w+1].havebomb)

if(w-1>

if(qipan[h][w-1].havebomb)

if(qipan[h][w+1].havebomb)

hight&

if(qipan[h+1][w-1].havebomb)

hight)

if(qipan[h+1][w].havebomb)

if(qipan[h+1][w+1].havebomb)

returnbombs;

falseshow()

¤

◎"

{

×

□"

flashshow()

hight;

width;

if(h==nhight&

w==nwidth)

○"

elseif(qipan[h][w].state==0)

"

check()

{

if(qipan[nhight][nwidth].state==0)

qipan[nhight][nwidth].state=10;

elseif(qipan[nhight][nwidth].state==10)

qipan[nhight][nwidth].state=0;

intfinded=0;

for(inths=0;

hs<

=hight;

hs++)

for(intws=0;

ws<

=width;

ws++)

if(qipan[hs][ws].state==10/*||qipan[hs][ws].state==0*/&

qipan[hs][ws].havebomb)

finded++;

//checkwherefindallbomb

if(finded==numbomb)//////////////////////////////////////////////////////error///////////////////////////////////////

return2;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2