多文件实现扫雷游戏,并满足:第一次不被炸死 ,当坐标周围没雷,可以实现展开
创建两个12*12的数组,一个实现埋雷等操作mine[12][12],另一个则是用户所见的界面board[12][12]。
在mine.h中进行一些文件引入和定义及声明
mine.h
#ifndef _MINE_H_
#define _MINE_H_
#pragma warning (disable:4996)
#include<stdio.h>
#include<string.h>
#include<Windows.h>
#include<time.h>
#define ROW 12
#define COL 12
#define MINE_NUM 20
#define TOTAL 100
void ShowBoard(char board[][COL], int row, int col);
void SetMine(char mine[][COL], int row,int col,int count);
char GetMine(char mine[][COL], char board[][COL], int row, int col);//char ->'0'-'8'
void Game();
#endif
在mine.c中进行扫雷游戏的实现
SetMine() :对mine[ROW][COL]进行埋雷操作
ShowBoard():玩家所见到的游戏界面
GetMine():当未踩到雷时,显示四周雷的个数,如果四周雷的个数为0,则对周围雷的个数进行展开。
GetRandIdex&