C's little game - minesweeper

illustrate:

1. Two arrays are defined, one is the chessboard array for Bray, and the other is the chessboard array displayed to the player.

2. This program has not been further optimized. It can only be realized that when the no-mine coordinates are clicked, the number of surrounding mines can be displayed at this point, but the surrounding area cannot be expanded.

Now let's take a look at the specific program:

1. In the header file, we define: the number of mines is 20, and the total number is 10*10



Second, we write the game menu in the main function, and how to enter the game.



Third, let's see how to play the game.

First let's take a look at the game function


Next we write the functions used in the main logic:

1. First look at how to mine


Let's see how to calculate the number of surrounding mines: (add the surrounding 8 contents)


Finally, we display the overall coordinates of the function:



 At this point our entire program has been written, let's take a look at the resulting graph:


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324725524&siteId=291194637