How to use C language to realize simple Minesweeper Game
This article mainly introduces how to use C language to achieve a simple mine clearance game, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
1. The header file # define _ CRT_SECURE_NO_WARNINGS// contains the header file # include # include / / definition value # define ROW 9#define COL 9#define ROWS ROW+2#define COLS COL+2// definition number # define mine_num 10impulse / function definition / / initialization void init_board (char board [ROWS] [COLS], int row, int col, char set); / / print chessboard void print_board (char board [ROWS] [COLS], int row, int col) / / minesweeping void set_mine (char mine [ROWS] [COLS], int row, int col); / minesweeping void find_mine (char mine [ROWS] [COLS], char board [ROWS] [COLS], int row, int col); 2. Game implementation function # include "game.h" / / initializing void init_board (char board [ROWS] [COLS], int row, int col, char set) {int x = 0; int y = 0; for (x = 0; x < row) ) {for (y = 0; y < col; y +) {board [x] [y] = set;}} / / print chessboard void print_board (char board [ROWS] [COLS], int row, int col) {int x = 0; int y = 0; for (x = 0; x = 1 & x