well,c语言简易扫雷
来源:互联网 发布:王士营养配餐软件 编辑:程序博客网 时间:2024/05/21 15:22
emmmmm,只能进行扫雷,不能标记,没有开版这一说(点一个就消失一个,不会出现消失一片),扫雷由键盘控制,异常麻烦。。。
以上,大概就是全部了。(注意坐标从0,0开始)
代码如下
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
char arr[1000][1000];
int brr[10001][1001];
int bon,x,y,i,j,count=0;
void mmap()
{
int dis[8][2]={-1,-1, -1,0, -1,1, 0,-1, 0,1, 1,-1, 1,0, 1,1};
for(i=0;i<bon;i++)
{
int temx,temy;
temx=rand()%x,temy=rand()%y;
if(arr[temx][temy]){i--;continue;}
arr[temx][temy]='*';
}
for(i=1;i<=x;i++)
{
for(j=1;j<=y;j++)
if(arr[i-1][j-1]=='*')
{
for(int k=0;k<8;k++)
brr[i+dis[k][0]][j+dis[k][1]]++;
}
}
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
printf(".");
printf("\n");
}
}
void play()
{
int tx,ty;
printf("the x? the y?\n");
scanf("%d%d",&tx,&ty);
system("clear");
if(arr[tx][ty]!='*')
{
if(arr[tx][ty]!='@')
count++;
arr[tx][ty]='@';
}
else{printf("you lose!\n");return;}
if(count==x*y-bon)
{
printf("you win!\n");
return;
}
for(i=1;i<=x;i++)
{
for(j=1;j<=y;j++)
{
if(arr[i-1][j-1]=='@')
printf("%d",brr[i][j]);
else printf(".");
}
printf("\n");
}
play();
}
int main()
{
while(1)
{
memset(arr,0,sizeof(arr));
memset(brr,0,sizeof(brr));
srand(time(0));
printf("please input the hight,width and boom\n");
scanf("%d%d%d",&x,&y,&bon);
mmap();
play();
printf("continue?(1/0)\n");
scanf("%d",&bon);
if(!bon)break;
}
printf("Thank you for play my simple game,may you success!");
return 0;
}
- well,c语言简易扫雷
- C语言:9*9>简易扫雷
- C语言实现简易版扫雷游戏
- C语言实现简易版扫雷
- 【C语言】简易扫雷游戏——C语言实现
- c语言实现扫雷(简易版,控制台)
- C语言“黑框框”下简易扫雷实现
- 简易小游戏扫雷——C语言编程实现
- 如何用C语言写出简易的扫雷程序
- C语言扫雷源码
- C语言扫雷程序
- C语言扫雷
- C语言扫雷基础
- C语言扫雷
- C语言小游戏“扫雷”
- C语言-扫雷游戏
- c语言编写扫雷
- c语言扫雷游戏
- eclipse配置maven + 创建maven项目
- 如何删除github上的某个文件夹
- 逻辑运算符解析
- 未能正确加载 “Microsoft.Entity.Design.BootstrapPackage.BootstrapPackage,Microsoft.Data.Entity未能正确加载 “Micro
- 对话框中怎样加入工具条综述
- well,c语言简易扫雷
- Maximum Sum of 3 Non-Overlapping Subarrays
- Html5 canvas学习1-描边 渐变 直线 矩形
- 安装虚拟机教程
- 皮尔逊相关系数和安斯库姆四重奏 pandas corr()函数
- [TensorFlow] demo1 创建100个float32的随机数x_data
- Java并发编程:CountDownLatch、CyclicBarrier和 Semaphore
- JSF 2.0 command button 为‘null Converter’设置值“......“时发生转换错误。
- linux 下安装python3