原创C语言扫雷程序大作业代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
}
int welcome()
{
int i,j,m,a,num;
printf("Hello,welcome to Bomb Hunter!\nFirst of all,please input the number of bombs(eg:30):\n");
scanf("%d",&num);
printf("Now let's begin,good luck!\n");
{
int i,j;
for (i=1;i<11;i++)
for (j=1;j<11;j++)
{
if(tru[i-1][j-1]=='/'||tru[i-1][j-1]=='*')
tbl[i+1][j+1]=tru[i-1][j-1];
}//---------------------------------tbl的最终刷新
int tru[10][10]={{},{},{},{},{},{},{},{},{},{}};//真相数组[truth](地雷数、地雷*、误判/、空白O)
int tbl[12][12]={{' ','X',1,2,3,4,5,6,7,8,9,10},
{'Y','+','-','-','-','-','-','-','-','-','-','-'},
srand((int)time(0));
for (m=0;m<num;)
{
a=random(100);//----------------------0到99生成随机数,取个位和十位
j=a%10+1;
i=(a-j)/10+1;
if(bomb[i][j]!=1)
{
bomb[i][j]=1;
m++;
}
}//------------------------------------地雷数组生成
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define random(x) (rand()%x)
int n=0;//-------------------------------------------完成度判断
int bomb[12][12]={{},{},{},{},{},{},{},{},{},{},{},{},};//地雷分布(地雷1、无雷0)
{
welcome();
do
{
game();
}
while (n<=9);//未胜利,继续进行游戏
if(n==10)
printf("Mission succeed!\n");//全部地雷标记完成,胜利
else
printf("Mission failed!\n");//n=11,引爆地雷,失败
return 0;
{1,'|','_','_','_','_','_','_','_','_','_','_'},
{2,'|','_','_','_','_','_','_','_'பைடு நூலகம்'_','_','_'},
{3,'|','_','_','_','_','_','_','_','_','_','_'},
{4,'|','_','_','_','_','_','_','_','_','_','_'},
{
int e,f;
for(e=1;e<11;e++)
for(f=1;f<11;f++)
{
if(bomb[e][f]==1)
tru[e-1][f-1]='*';
else
tru[e-1][f-1]='_';
}
return 0;
}
int updt_tbl()//---------------------------------游戏中棋盘的更新
{5,'|','_','_','_','_','_','_','_','_','_','_'},
{6,'|','_','_','_','_','_','_','_','_','_','_'},
{7,'|','_','_','_','_','_','_','_','_','_','_'},
{8,'|','_','_','_','_','_','_','_','_','_','_'},
printf("%3c",tbl[s][t]);//---------------------------打印字符
{9,'|','_','_','_','_','_','_','_','_','_','_'},
{10,'|','_','_','_','_','_','_','_','_','_','_'}}; //棋盘数组[table](坐标系|-12、地雷数、红旗P、地雷*、爆炸X、误判/)
int main()//---------------------主函数
return 0;
}
int dspl()//----------------------------棋盘打印函数[display]
{
int s,t;
updt_tbl();
printf("\n");
for(s=0;s<12;s++)
{
for(t=0;t<12;t++)
if(tbl[s][t]=='_'||tbl[s][t]=='*'||tbl[s][t]=='X'||tbl[s][t]=='P'||tbl[s][t]=='/'||tbl[s][t]=='O'||tbl[s][t]=='+'||tbl[s][t]=='-'||tbl[s][t]=='|'||tbl[s][t]=='_'||tbl[s][t]==' '||tbl[s][t]=='Y')
printf("loading...\n");
updt_tru();//---------------tru生成
dspl();//-------------------打印棋盘
return 0;
}
int updt_tru()//---------------------------真相数组的生成[update_truth]
{
int i,j;
for (i=1;i<11;i++)
for (j=1;j<11;j++)
{
if(tru[i-1][j-1]!='/'&&tru[i-1][j-1]!='*')
tbl[i+1][j+1]=tru[i-1][j-1];
}
return 0;
}
int fnl_tbl()//-----------------------------结局棋盘的更新[final_table]
int welcome()
{
int i,j,m,a,num;
printf("Hello,welcome to Bomb Hunter!\nFirst of all,please input the number of bombs(eg:30):\n");
scanf("%d",&num);
printf("Now let's begin,good luck!\n");
{
int i,j;
for (i=1;i<11;i++)
for (j=1;j<11;j++)
{
if(tru[i-1][j-1]=='/'||tru[i-1][j-1]=='*')
tbl[i+1][j+1]=tru[i-1][j-1];
}//---------------------------------tbl的最终刷新
int tru[10][10]={{},{},{},{},{},{},{},{},{},{}};//真相数组[truth](地雷数、地雷*、误判/、空白O)
int tbl[12][12]={{' ','X',1,2,3,4,5,6,7,8,9,10},
{'Y','+','-','-','-','-','-','-','-','-','-','-'},
srand((int)time(0));
for (m=0;m<num;)
{
a=random(100);//----------------------0到99生成随机数,取个位和十位
j=a%10+1;
i=(a-j)/10+1;
if(bomb[i][j]!=1)
{
bomb[i][j]=1;
m++;
}
}//------------------------------------地雷数组生成
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define random(x) (rand()%x)
int n=0;//-------------------------------------------完成度判断
int bomb[12][12]={{},{},{},{},{},{},{},{},{},{},{},{},};//地雷分布(地雷1、无雷0)
{
welcome();
do
{
game();
}
while (n<=9);//未胜利,继续进行游戏
if(n==10)
printf("Mission succeed!\n");//全部地雷标记完成,胜利
else
printf("Mission failed!\n");//n=11,引爆地雷,失败
return 0;
{1,'|','_','_','_','_','_','_','_','_','_','_'},
{2,'|','_','_','_','_','_','_','_'பைடு நூலகம்'_','_','_'},
{3,'|','_','_','_','_','_','_','_','_','_','_'},
{4,'|','_','_','_','_','_','_','_','_','_','_'},
{
int e,f;
for(e=1;e<11;e++)
for(f=1;f<11;f++)
{
if(bomb[e][f]==1)
tru[e-1][f-1]='*';
else
tru[e-1][f-1]='_';
}
return 0;
}
int updt_tbl()//---------------------------------游戏中棋盘的更新
{5,'|','_','_','_','_','_','_','_','_','_','_'},
{6,'|','_','_','_','_','_','_','_','_','_','_'},
{7,'|','_','_','_','_','_','_','_','_','_','_'},
{8,'|','_','_','_','_','_','_','_','_','_','_'},
printf("%3c",tbl[s][t]);//---------------------------打印字符
{9,'|','_','_','_','_','_','_','_','_','_','_'},
{10,'|','_','_','_','_','_','_','_','_','_','_'}}; //棋盘数组[table](坐标系|-12、地雷数、红旗P、地雷*、爆炸X、误判/)
int main()//---------------------主函数
return 0;
}
int dspl()//----------------------------棋盘打印函数[display]
{
int s,t;
updt_tbl();
printf("\n");
for(s=0;s<12;s++)
{
for(t=0;t<12;t++)
if(tbl[s][t]=='_'||tbl[s][t]=='*'||tbl[s][t]=='X'||tbl[s][t]=='P'||tbl[s][t]=='/'||tbl[s][t]=='O'||tbl[s][t]=='+'||tbl[s][t]=='-'||tbl[s][t]=='|'||tbl[s][t]=='_'||tbl[s][t]==' '||tbl[s][t]=='Y')
printf("loading...\n");
updt_tru();//---------------tru生成
dspl();//-------------------打印棋盘
return 0;
}
int updt_tru()//---------------------------真相数组的生成[update_truth]
{
int i,j;
for (i=1;i<11;i++)
for (j=1;j<11;j++)
{
if(tru[i-1][j-1]!='/'&&tru[i-1][j-1]!='*')
tbl[i+1][j+1]=tru[i-1][j-1];
}
return 0;
}
int fnl_tbl()//-----------------------------结局棋盘的更新[final_table]