扫雷(C语言)(展开一片)(标记)

扫雷(C语言)(展开一片)(标记),第1张

文章目录
  • 1.打印菜单
  • 2.初始化棋盘
  • 3.打印棋盘
  • 4.布置雷
  • 5.排雷
    • 5.1计算周围雷个数
    • 5.2展开一片函数
    • 5.3标记雷
    • 5.4判断胜利
  • 6.完整代码
    • 6.1 test.c
    • 6.2 game.c
    • 6.3 game.h
    • 6.4展示结果
      • 6.4.1成功
      • 6.4.2失败

1.打印菜单

首先我们先打印玩游戏的菜单,玩游戏不过瘾想再玩一次,用do while循环打印菜单

#define _CRT_SECURE_NO_WARNINGS
#include "game.h"
void menu()
{
	printf("************************\n");
	printf("*******  1.play  *******\n");
	printf("*******  0.exit  *******\n");
	printf("************************\n");
}
int main()
{
	int input = 0;
	do
	{
		menu();
		printf("请选择:>");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			printf("扫雷\n");
			break;
		case 0:
			printf("退出游戏\n");
			break;
		default:
			printf("选择错误,请重新输入\n");
			break;
		}
	} while (input);
	return 0;
}

效果如下:

************************
*******  1.play  *******
*******  0.exit  *******
************************
请选择:>1
扫雷
************************
*******  1.play  *******
*******  0.exit  *******
************************
请选择:>8
选择错误,请重新输入
************************
*******  1.play  *******
*******  0.exit  *******
************************
请选择:>0
退出游戏
2.初始化棋盘

我们要做的是一个9*9的扫雷棋盘,方格中数字则表示其周围的8个方格隐藏了几颗雷.

但是当排查角格周围的雷时,角格周围只有3个格子可以排查,剩下5个格子在棋盘外面,所以我们可以把棋盘扩展一圈。

相当于行增加2行,列增加2列,
9—>11

#define ROW 9
#define COL 9
#define ROWS ROW+2
#define COLS COL+2

我们需要创建一个mine棋盘显示布置雷的信息,再创建一个show棋盘显示排查雷的信息。

void init_board(char board[ROWS][COLS], int rows, int cols, int set)
{
	int i = 0;
	int j = 0;
	for (i = 0; i < rows; i++)
	{
		for (j = 0; j < cols; j++)
		{
			board[i][j] = set;
		}
	}
}

mine棋盘初始化为‘0’,有雷则为‘1’;
show棋盘初始化为‘*’表示没有排查过,排查过则显示数字字符代表周围8个格子里的雷和

    init_board(mine, ROWS, COLS,'0');
	init_board(show, ROWS, COLS,'*');
3.打印棋盘

初始化好之后打印两个棋盘

void display_board(char board[ROWS][COLS], int row, int col)
{
	printf("------扫雷游戏-----\n");//添加分界线方便观察
	int i = 0;
	int j = 0;
	for (j = 0; j <= col; j++)
	{
		printf("%d ", j);
	}
	printf("\n");
	for (i = 1; i <= row; i++)
	{
		printf("%d ", i);
		for (j = 1; j <=col; j++)
		{
			printf("%c ", board[i][j]);
		}
		printf("\n");
	}
	printf("------扫雷游戏-----\n");
}

效果如下:

------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0
------扫雷游戏-----
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * * * * *
5 * * * * * * * * *
6 * * * * * * * * *
7 * * * * * * * * *
8 * * * * * * * * *
9 * * * * * * * * *
------扫雷游戏-----

标记好行号和列号,方便输入每个方格的坐标。

4.布置雷

我做的是简单模式,布置10个雷。

用到rand()函数,rand产生0到32767之间的随机数
rand()%9—>0到8;
rand()%9+1—>产生1~9之间的随机数

void SetMine(char mine[ROWS][COLS], int row, int col)
{
	int count = 0;
	while (count < easy_count)
	{
		int x = 0;
		int y = 0;
		x = rand() % row + 1;
		y = rand() % col + 1;
		if (mine[x][y] == '0')
		{
			mine[x][y] = '1';
			count++;
		}
	}
}

效果如下

------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 1 0 0 0 0 0 0 0 0
2 0 1 0 0 0 0 0 1 0
3 0 0 0 0 0 0 0 1 0
4 0 0 0 0 1 0 0 0 0
5 1 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 1
7 0 0 1 1 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 1 0 0
------扫雷游戏-----
5.排雷

接下来我们开始排雷,mine和show两个数组都要调用。

void FindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col)
{
	while (1)
	{
		int x = 0;
		int y = 0;
		printf("请输入要排查的坐标:>");
		scanf("%d %d", &x, &y);
		if (x >= 1 && x <= row && y >= 1 && y <= col)//保证不越界
		{
			if (show[x][y] != '*')
			{
				printf("该坐标已被排查,请重新输入\n");
			}
			else
			{
				if (mine[x][y] == '1')
				{
					printf("很遗憾,你被炸死了\n");
					display_board(mine, ROW, COL);
					break;
				}
				else
				{
					OpenUp(mine, show, ROW, COL, x, y);//如果该坐标不是雷,周围没有雷,实现打开一片
					display_board(show, ROW, COL);
					SignMine(show, ROW, COL);//标记雷
					display_board(show, ROW, COL);
					int ret=IsWin(show, ROW, COL);
					if (ret == easy_count)
					{
						printf("恭喜你,排雷成功\n");
						display_board(mine, ROW, COL);
						break;
					}
				}
			}
		}
		else
		{
			printf("坐标非法,请重新输入\n");
		}
	}
}
5.1计算周围雷个数

布置雷的棋盘里面是雷为’1’,非雷为’0’
‘1’-‘0’=1
(字符1的ascii码值为49,字符0的ascii码值为48,相减等于数字1。)
‘0’-‘0’=0

int RoundMine(char mine[ROWS][COLS], int x, int y)
{
	return mine[x - 1][y - 1] +
		mine[x - 1][y] +
		mine[x - 1][y + 1] +
		mine[x][y - 1] +
		mine[x][y + 1] +
		mine[x + 1][y - 1] +
		mine[x + 1][y] +
		mine[x + 1][y + 1] - 8 * '0';
}
5.2展开一片函数

用递归来实现
前提条件:①该坐标不是雷,②该坐标周围没有雷,③该坐标没有被排查过,④该坐标没有越界

void OpenUp(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col, int x, int y)
{
	int ret = RoundMine(mine, x, y);
	if (ret == 0)
	{
		show[x][y] = ' ';
		if(x-1>0&&y-1>0&&show[x-1][y-1]=='*')
			OpenUp(mine, show, ROW, COL, x-1, y-1);
		if(x-1>0&&show[x-1][y])
			OpenUp(mine, show, ROW, COL, x - 1, y);
		if(x - 1 >0&&y+1<=col&&show[x-1][y+1]=='*')
			OpenUp(mine, show, ROW, COL, x - 1, y+1);
		if(y-1>0&&show[x][y-1]=='*')
			OpenUp(mine, show, ROW, COL, x , y - 1);
		if(y+1<=col&&show[x][y+1]=='*')
			OpenUp(mine, show, ROW, COL, x, y + 1);
		if(x+1<=row&&y-1>0&&show[x+1][y-1]=='*')
			OpenUp(mine, show, ROW, COL, x+1, y-1);
		if(x+1<=row&&show[x+1][y]=='*')
			OpenUp(mine, show, ROW, COL, x + 1, y);
		if (x + 1 <=row && y + 1 <=col&&show[x+1][y+1]=='*')
			OpenUp(mine, show, ROW, COL, x + 1, y + 1);
	}
	else
	{
		show[x][y] = ret + '0';
	}
}

效果如下:

------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * * * * *
5 * * * * * * * * *
6 * * * * * * * * *
7 * * * * * * * * *
8 * * * * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请输入要排查的坐标:>3 3
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * 1     1 * * * *
2 * 1     1 * * * *
3 1 1   1 2 * * * *
4       1 * * * * *
5     1 2 * * * * *
6     1 * * * * * *
7   1 2 * * * * * *
8   1 * * * * * * *
9   1 * * * * * * *
------扫雷游戏-----
5.3标记雷
void SignMine(char show[ROWS][COLS], int row, int col)
{
	int sign = 0;
	do
	{
		printf("请选择是否标记(1/0):>");
		scanf("%d", &sign);
		switch (sign)
		{
		case 1:
			printf("请输入要标记的坐标:>");
			int x = 0;
			int y = 0;
			scanf("%d %d", &x, &y);
			if (x >= 1 && x <= row && y >= 1 && y <= col)
			{
				if (show[x][y] == '*')
				{
					show[x][y] = '@';
					display_board(show, ROW, COL);
				}
				else if (show[x][y] == '@')
				{
                    show[x][y] = '*';//取消标记
					display_board(show, ROW, COL);
				}
					
				else
					printf("该坐标已被排查\n");
			}
			else
				printf("坐标非法\n");
			break;
		case 0:
			break;
		default:
			break;
		}
	} while (sign);
}

效果如下:

------扫雷游戏-----
请输入要排查的坐标:>2 7
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * 1   1 * 1
2 1 1   2 * 2
3       2 * 2 1 1 1
4       1 2 * * * *
5         1 * * * *
6 1 1 1   1 1 1 1 *
7 * * 2         1 1
8 * * 2   1 1 1
9 * * 1   1 * 1
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>1 1
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 @ 1   1 * 1
2 1 1   2 * 2
3       2 * 2 1 1 1
4       1 2 * * * *
5         1 * * * *
6 1 1 1   1 1 1 1 *
7 * * 2         1 1
8 * * 2   1 1 1
9 * * 1   1 * 1
------扫雷游戏-----
请选择是否标记(1/0):>
5.4判断胜利

遍历数组每个元素,如果没有被排查的和已经被标记的和等于雷的个数,则排雷成功。

int IsWin(char show[ROWS][COLS], int row, int col)
{
	int win = 0;
	int i = 0;
	int j = 0;
	for (i = 1; i <= row; i++)
	{
		for (j = 1; j <= col; j++)
		{
			if (show[i][j] == '*' || show[i][j] == '@')
				win++;
		}
	}
	return win;
}
6.完整代码 6.1 test.c
#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 };
	init_board(mine, ROWS, COLS,'0');
	init_board(show, ROWS, COLS,'*');
	SetMine(mine, ROW, COL);
	display_board(mine, ROW, COL);
	display_board(show, ROW, COL);
	FindMine(mine, show, ROW, COL);
}
int main()
{
	srand((unsigned int)time(NULL));
	int input = 0;
	do
	{
		menu();
		printf("请选择:>");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			system("cls");
			game();
			system("pause");
			system("cls");

			break;
		case 0:

			printf("退出游戏\n");
			system("pause");
			system("cls");

			break;
		default:
			printf("选择错误,请重新输入\n");
			system("pause");
			system("cls");
			break;
		}
	} while (input);
	return 0;
}
6.2 game.c
#define _CRT_SECURE_NO_WARNINGS
#include "game.h"
void init_board(char board[ROWS][COLS], int rows, int cols, int set)
{
	int i = 0;
	int j = 0;
	for (i = 0; i < rows; i++)
	{
		for (j = 0; j < cols; j++)
		{
			board[i][j] = set;
		}
	}
}
void display_board(char board[ROWS][COLS], int row, int col)
{
	printf("------扫雷游戏-----\n");
	int i = 0;
	int j = 0;
	for (j = 0; j <= col; j++)
	{
		printf("%d ", j);
	}
	printf("\n");
	for (i = 1; i <= row; i++)
	{
		printf("%d ", i);
		for (j = 1; j <=col; j++)
		{
			printf("%c ", board[i][j]);
		}
		printf("\n");
	}
	printf("------扫雷游戏-----\n");
}
void SetMine(char mine[ROWS][COLS], int row, int col)
{
	int count = 0;
	while (count < easy_count)
	{
		int x = 0;
		int y = 0;
		x = rand() % row + 1;
		y = rand() % col + 1;
		if (mine[x][y] == '0')
		{
			mine[x][y] = '1';
			count++;
		}
	}
}
int RoundMine(char mine[ROWS][COLS], int x, int y)
{
	return mine[x - 1][y - 1] +
		mine[x - 1][y] +
		mine[x - 1][y + 1] +
		mine[x][y - 1] +
		mine[x][y + 1] +
		mine[x + 1][y - 1] +
		mine[x + 1][y] +
		mine[x + 1][y + 1] - 8 * '0';
}
void OpenUp(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col, int x, int y)
{
	int ret = RoundMine(mine, x, y);
	if (ret == 0)
	{
		show[x][y] = ' ';
		if(x-1>0&&y-1>0&&show[x-1][y-1]=='*')
			OpenUp(mine, show, ROW, COL, x-1, y-1);
		if(x-1>0&&show[x-1][y])
			OpenUp(mine, show, ROW, COL, x - 1, y);
		if(x - 1 >0&&y+1<=col&&show[x-1][y+1]=='*')
			OpenUp(mine, show, ROW, COL, x - 1, y+1);
		if(y-1>0&&show[x][y-1]=='*')
			OpenUp(mine, show, ROW, COL, x , y - 1);
		if(y+1<=col&&show[x][y+1]=='*')
			OpenUp(mine, show, ROW, COL, x, y + 1);
		if(x+1<=row&&y-1>0&&show[x+1][y-1]=='*')
			OpenUp(mine, show, ROW, COL, x+1, y-1);
		if(x+1<=row&&show[x+1][y]=='*')
			OpenUp(mine, show, ROW, COL, x + 1, y);
		if (x + 1 <=row && y + 1 <=col&&show[x+1][y+1]=='*')
			OpenUp(mine, show, ROW, COL, x + 1, y + 1);
	}
	else
	{
		show[x][y] = ret + '0';
	}
}
void SignMine(char show[ROWS][COLS], int row, int col)
{
	int sign = 0;
	do
	{
		printf("请选择是否标记(1/0):>");
		scanf("%d", &sign);
		switch (sign)
		{
		case 1:
			printf("请输入要标记的坐标:>");
			int x = 0;
			int y = 0;
			scanf("%d %d", &x, &y);
			if (x >= 1 && x <= row && y >= 1 && y <= col)
			{
				if (show[x][y] == '*')
				{
					show[x][y] = '@';
					display_board(show, ROW, COL);
				}
				else if (show[x][y] == '@')
				{
                    show[x][y] = '*';//取消标记
					display_board(show, ROW, COL);
				}
					
				else
					printf("该坐标已被排查\n");
			}
			else
				printf("坐标非法\n");
			break;
		case 0:
			break;
		default:
			break;
		}
	} while (sign);
}
int IsWin(char show[ROWS][COLS], int row, int col)
{
	int win = 0;
	int i = 0;
	int j = 0;
	for (i = 1; i <= row; i++)
	{
		for (j = 1; j <= col; j++)
		{
			if (show[i][j] == '*' || show[i][j] == '@')
				win++;
		}
	}
	return win;
}

void FindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col)
{
	while (1)
	{
		int x = 0;
		int y = 0;
		printf("请输入要排查的坐标:>");
		scanf("%d %d", &x, &y);
		if (x >= 1 && x <= row && y >= 1 && y <= col)
		{
			if (show[x][y] != '*')
			{
				printf("该坐标已被排查,请重新输入\n");
			}
			else
			{
				if (mine[x][y] == '1')
				{
					printf("很遗憾,你被炸死了\n");
					display_board(mine, ROW, COL);
					break;
				}
				else
				{
					OpenUp(mine, show, ROW, COL, x, y);
					display_board(show, ROW, COL);
					SignMine(show, ROW, COL);
					display_board(show, ROW, COL);
					int ret=IsWin(show, ROW, COL);
					if (ret == easy_count)
					{
						printf("恭喜你,排雷成功\n");
						display_board(mine, ROW, COL);
						break;
					}
				}
			}
		}
		else
		{
			printf("坐标非法,请重新输入\n");
		}
	}
}
6.3 game.h
#define _CRT_SECURE_NO_WARNINGS
#include 
#include 
#include 
#define ROW 9
#define COL 9
#define ROWS ROW+2
#define COLS COL+2
#define easy_count 10
void init_board(char board[ROWS][COLS], int rows, int cols,int set);
void display_board(char board[ROWS][COLS], int row, int col);
void SetMine(char mine[ROWS][COLS], int row, int col);
void FindMine(char mine[ROWS][COLS],char show[ROWS][COLS], int row, int col);

6.4展示结果 6.4.1成功
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * * * * *
5 * * * * * * * * *
6 * * * * * * * * *
7 * * * * * * * * *
8 * * * * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请输入要排查的坐标:>4 2
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 * * * * *
2     1 2 * * * * *
3     1 * * * * * *
4     1 * * * * * *
5     1 * * * * * *
6     2 * * * * * *
7     2 * * * * * *
8 1 2 3 * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 * * * * *
2     1 2 * * * * *
3     1 * * * * * *
4     1 * * * * * *
5     1 * * * * * *
6     2 * * * * * *
7     2 * * * * * *
8 1 2 3 * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请输入要排查的坐标:>6 8
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 * * * * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * * 1 1 1 1
8 1 2 3 * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 * * * * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * * 1 1 1 1
8 1 2 3 * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请输入要排查的坐标:>8 6
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 * * * * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>1 5
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ * * * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>1 6
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ * * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ * * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>1 7
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 * *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>1 8
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 *
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>1 9
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 *
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>2 9
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 * 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>3 4
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 * 1
5     1 * 2 1
6     2 * * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>6 4
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 * 1
5     1 * 2 1
6     2 @ * 1
7     2 * 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>1
请输入要标记的坐标:>7 4
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 * 1
5     1 * 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 * 1
5     1 * 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>4 4
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 * 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 * 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>5 4
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * *
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>8 9
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 * * * 1     1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 * * * 1     1 * *
------扫雷游戏-----
请输入要排查的坐标:>9 8
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 * * * 1     1 1 *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 * * * 1     1 1 *
------扫雷游戏-----
请输入要排查的坐标:>9 9
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 * * * 1     1 1 1
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 * * * 1     1 1 1
------扫雷游戏-----
请输入要排查的坐标:>9 1
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 1 * * 1     1 1 1
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1       1 @ @ 1 1 1
2     1 2 3 2 1 1 @
3     1 @ 1     1 1
4     1 1 1
5     1 2 2 1
6     2 @ * 1
7     2 @ 3 1 1 1 1
8 1 2 3 2 1   1 * 1
9 1 * * 1     1 1 1
------扫雷游戏-----
恭喜你,排雷成功
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 0 0 0 0 1 1 0 0 0
2 0 0 0 0 0 0 0 0 1
3 0 0 0 1 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0
6 0 0 0 1 1 0 0 0 0
7 0 0 0 1 0 0 0 0 0
8 0 0 0 0 0 0 0 1 0
9 0 1 1 0 0 0 0 0 0
------扫雷游戏-----
请按任意键继续. . .


6.4.2失败
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * * * * *
5 * * * * * * * * *
6 * * * * * * * * *
7 * * * * * * * * *
8 * * * * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请输入要排查的坐标:>7 2
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * * * * *
5 * * * * * * * * *
6 * * * * * * * * *
7 * 1 * * * * * * *
8 * * * * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * * * * *
5 * * * * * * * * *
6 * * * * * * * * *
7 * 1 * * * * * * *
8 * * * * * * * * *
9 * * * * * * * * *
------扫雷游戏-----
请输入要排查的坐标:>6 7
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * 1 1 1 1
5 * * * * * 1
6 * * * * * 1
7 1 1 1 * 2 1
8     1 1 1   1 1 1
9             1 * *
------扫雷游戏-----
请选择是否标记(1/0):>0
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 * * * * * * * * *
2 * * * * * * * * *
3 * * * * * * * * *
4 * * * * * 1 1 1 1
5 * * * * * 1
6 * * * * * 1
7 1 1 1 * 2 1
8     1 1 1   1 1 1
9             1 * *
------扫雷游戏-----
请输入要排查的坐标:>2 2
很遗憾,你被炸死了
------扫雷游戏-----
0 1 2 3 4 5 6 7 8 9
1 0 0 0 0 0 0 0 0 1
2 0 1 0 0 0 0 0 0 0
3 0 0 0 0 1 0 0 1 0
4 0 1 0 0 0 0 0 0 0
5 0 0 0 1 0 0 0 0 0
6 1 0 0 0 1 0 0 0 0
7 0 0 0 1 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 1 0
------扫雷游戏-----
请按任意键继续. . .

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/874610.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存