In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use C language to achieve a simple minesweeper game". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Construction of the main function int main () {int input = 0; do {menu (); printf ("Please choose whether or not to start the game (1Accord 0): >"); scanf ("% d", & input); switch (input) {case 1: game (); break; case 0: printf ("Game out!") ; break; default: printf ("input error! please re-enter:"); break;}} while (input); return 0;}
Create the main function and menu, and judge the game selection.
two。 Design of the mineplate char mine [ROWS] [COLS]; / / minesweeping array char show [ROWS] [COLS]; / / display array InitMine (mine, ROWS, COLS,'0'); / / initialization of the mineplate InitShow (show, ROW, COL,'*'); / / initialization of the displayed mineplate
Here we create two two-dimensional arrays, the mine array is used to lay mines, and the show array is used to show the situation of the mineplate.
The InitMine function is implemented as follows:
Void InitMine (char mine [ROWS] [COLS], int row, int col) / / initialize the mineplate {int I = 0; int j = 0; for (I = 0; I < row; iTunes +) {for (j = 0; j < col; jacks +) {mine [I] [j] = '0mm;}
Next we need to show the lightning disk, but we will not show the mine that will be placed, so we use the show function to help us achieve this requirement.
The InitShow function is implemented as follows:
Void InitShow (char show [ROWS] [COLS], int row, int col,char set) / / initialize the displayed mineplate {int I = 0; int j = 0; for (I = 1; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.