C语言实现简易扫雷
2021-04-02 06:26
标签:玩家 win put fine crt for sign while 语言 text.c game.c C语言实现简易扫雷 标签:玩家 win put fine crt for sign while 语言 原文地址:https://blog.51cto.com/14893161/2520622#define _CRT_SECURE_NO_WARNINGS 1
#include
#include "game.h"
void saolie()
{
char arr1[ROWS][COLS] = { 0 };
char arr2[ROWS][COLS] = { 0 };
//创建两个数组,一个放雷,一个显示
chushihua(arr1, ROWS, COLS, ‘0‘);
chushihua(arr2, ROWS, COLS, ‘*‘); //初始化两个棋盘
qipanxianshi(arr2,ROW,COL); //打印一下棋盘
buzhilie(arr1, ROW, COL); //放置地雷
qipanxianshi(arr1, ROW, COL); //测试打印一下带雷的棋盘
kaishipailei(arr1,arr2,ROW,COL);
}
void meun()
{
printf("================================\n");
printf("=========== 1.开 始 ===========\n");
printf("=========== 0.退 出 ===========\n");
printf("================================\n");
}
void game()
{
int input = 0;
srand((unsigned int)time(NULL));
do
{
meun();
printf("请选择:>");
scanf("%d", &input);
switch (input)
{
case 1:
saolie();
break;
case 0:
printf("游戏结束\n");
break;
default:
printf("输入错误\n");
break;
}
} while (input);
}
int main()
{
game();
return 0;
}
#include "game.h"
void chushihua(char arr[ROWS][COLS], int rows, int cols, char set)
{
int i = 0;
int j = 0;
for ( i = 0; i ");
scanf("%d%d", &num1, &num2);
if (num1 >= 1 && num1 = 1 && num2