Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use C language to realize simple Minesweeper Game

Shulou Source: shulou.com Published: 2022-06-02 02:30:41 10月02日 Update

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

Tags: Chessboard minesweeping minesweeping articles selection simplicity language functions coordinates files menus input legality success main program value interest legitimacy at the same time numerical values Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Tech Info Huawei NVidia Microsoft