-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
55 lines (48 loc) · 1.14 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#define _CRT_SECURE_NO_WARNINGS
#include "game.h"
void menu()
{
printf("***************************\n");
printf("********* 1.play *********\n");
printf("********* 0.exit *********\n");
printf("***************************\n");
}
void game()
{
char mine[ROWS][COLS] = {0}; //布置好的雷的信息
char show[ROWS][COLS] = {0}; //存放排查出的雷的信息
//初始化棋盘
InitBoard(mine, ROWS, COLS, '0'); //'0'
InitBoard(show, ROWS, COLS, '*'); //'*'
//打印一下棋盘
DisplayBoard(show, ROW, COL);
//布置雷
SetMine(mine,ROW,COL);
//DisplayBoard(mine, ROW, COL);
//排查雷
FindMine(mine,show,ROW,COL);
}
int main()
{
int input = 0;
srand((unsigned int)time(NULL)); //rand函数与srand函数的头文件是:<stdlib.h>和<time.h>
do //(unsigned int)为将time函数返回值强制类型转化为无符号的整型
{
menu();
printf("请选择:>");
scanf("%d", &input);
switch (input)
{
case 1:
game(); //扫雷游戏
break;
case 0:
printf("退出游戏\n");
break;
default:
printf("选择错误,重新选择\n");
break;
}
} while (input);
return 0;
}