-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmines_main.c
66 lines (62 loc) · 1.09 KB
/
mines_main.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
56
57
58
59
60
61
62
63
64
65
66
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "mines.h"
void meun()//打印菜单
{
printf(" Welcome to mines \n");
printf("---------------------------\n");
printf("----- 1.Start game. ----\n");
printf("----- 0.Exit game. ----\n");
printf("---------------------------\n");
}
void game()//开始游戏
{
char mine[ROW][COL];
char show[ROW][COL];
char ret = 0;
srand((unsigned)time(NULL));
initgame(mine, show, ROW, COL);
#if DEBUG
display(mine,ROW,COL);
#endif
display(show,ROW,COL);
while(1)
{
ret = play(mine, show, ROW, COL);
if('w' == ret)
{
display(mine,ROW,COL);
printf("You win!\n");
break;
}
if('*' == ret)
{
display(mine,ROW,COL);
printf("You lose!\n");
break;
}
#if DEBUG
display(mine,ROW,COL);
#endif
display(show,ROW,COL);
}
}
int main() //主函数
{
int input = 0;
do
{
meun();
printf("Please select >: ");
scanf("%d", &input);
switch(input)
{
case 1:game();break;
case 0:printf("Exit...\n");break;
default:printf("Error select! \n");
}
}while(input);
return 0;
}