日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java扫雷随机地雷_原创扫雷(未添加随机分布地雷),想看就进来看下吧

發布時間:2023/12/15 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java扫雷随机地雷_原创扫雷(未添加随机分布地雷),想看就进来看下吧 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

該樓層疑似違規已被系統折疊?隱藏此樓查看此樓

/* 里面涉及的知識主要是遞歸和數組 */

#include "stdio.h"

#include "conio.h"

int count=0;

void mark(int mobang[11][11],char xianxi[11][11],int x,int y)

{

xianxi[x][y]=' ';count++;

if((x-1)<1||(y-1)<1||(xianxi[x-1][y-1]==' '));else { if(mobang[x-1][y-1]!=0){xianxi[x-1][y-1]=' ';count++;} else mark(mobang,xianxi,x-1,y-1);}

if((x-1)<1||(xianxi[x-1][y]==' '));else { if(mobang[x-1][y]!=0){xianxi[x-1][y]=' ';count++;} else mark(mobang,xianxi,x-1,y);}

if((x-1)<1||(y+1)>9||(xianxi[x-1][y+1]==' '));else { if(mobang[x-1][y+1]!=0){xianxi[x-1][y+1]=' ';count++;} else mark(mobang,xianxi,x-1,y+1);}

if((y-1)<1||(xianxi[x][y-1]==' '));else { if(mobang[x][y-1]!=0){xianxi[x][y-1]=' ';count++;} else mark(mobang,xianxi,x,y-1);}

if((y+1)>9||(xianxi[x][y+1]==' '));else { if(mobang[x][y+1]!=0){xianxi[x][y+1]=' ';count++;} else mark(mobang,xianxi,x,y+1);}

if((x+1)>9||(y-1)<1||(xianxi[x+1][y-1]==' '));else { if(mobang[x+1][y-1]!=0){xianxi[x+1][y-1]=' ';count++;} else mark(mobang,xianxi,x+1,y-1);}

if((x+1)>9||(xianxi[x+1][y]==' '));else { if(mobang[x+1][y]!=0){xianxi[x+1][y]=' ';count++;} else mark(mobang,xianxi,x+1,y);}

if((x+1)>9||(y+1)>9||(xianxi[x+1][y+1]==' '));else { if(mobang[x+1][y+1]!=0){xianxi[x+1][y+1]=' ';count++;} else mark(mobang,xianxi,x+1,y+1);}

}

int main(void)

{

int mobang[11][11]={0};

char xianxi[11][11]={'*'};

int i,j;

int count1=0;

int zhonglei=0;

int flag1=0;

int flag2=0;

int choice1,choice2;

mobang[1][2]=mobang[2][7]=mobang[2][8]=9;

mobang[5][5]=mobang[6][4]=mobang[7][4]=9;

mobang[8][7]=mobang[9][1]=mobang[9][7]=9;

for(i=1;i<10;i++)

{

for(j=1;j<10;j++)

{

if(mobang[i][j]==9);

else {

if(mobang[i-1][j-1]==9) count1++;

if(mobang[i-1][j]==9) count1++;

if(mobang[i-1][j+1]==9) count1++;

if(mobang[i][j-1]==9) count1++;

if(mobang[i][j+1]==9) count1++;

if(mobang[i+1][j-1]==9) count1++;

if(mobang[i+1][j]==9) count1++;

if(mobang[i+1][j+1]==9) count1++;

mobang[i][j]=count1;

}

count1=0;

}

}

for(i=1;i<11;i++)

for(j=1;j<11;j++) xianxi[i][j]='*';

while(1)

{

printf("???? 1 2 3 4 5 6 7 8 9 ");

for(i=1;i<10;i++)

{

if(i!=1)printf("\n??? ---------------------------\n %d|",i);else printf("\n??? ===========================\n %d|",i);

for(j=1;j<10;j++)

{

if(xianxi[i][j]=='*')printf(" *|");

else

{

switch(mobang[i][j])

{

case 0: printf(" |");break;

case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8: printf("%2d|",mobang[i][j]);break;

case 9: printf(" #|");break;

default:;

}

}

}

}

if(zhonglei==1||count>=72)break;

printf("\n\n\n\n\nInput a number:");

count1=0;

flag1=0;

flag2=0;

while(1)

{

switch(count1)

{

case 0: {choice1=getchar(); if(choice1==10){ choice1=0;flag1=1; break;}}

case 1: {choice2=getchar(); if(choice2==10){ choice2=0;flag1=1; break;}}

default: if(getchar()=='\n') flag2=1;

}

if(flag1==1||flag2==1)break;

count1++;

}

if(flag1==1||choice1<49||choice1>57||choice2<49||choice2>57)continue;else {choice1-=48;choice2-=48;}

if(xianxi[choice1][choice2]==' ')continue;

if(mobang[choice1][choice2]==9){xianxi[choice1][choice2]=' ';zhonglei=1;}

else {

if(mobang[choice1][choice2]!=0) {xianxi[choice1][choice2]=' ';count++;}

else mark(mobang,xianxi,choice1,choice2);

}

}

if(zhonglei==1)printf("\n\n\n\nYou lose! GAME OVER!");

else printf("\n\n\n\nWell done, my hero! You win!");

getch();

return 0;

}

總結

以上是生活随笔為你收集整理的java扫雷随机地雷_原创扫雷(未添加随机分布地雷),想看就进来看下吧的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。