用c语言编写一个程序,部分代码已给出,部分代码在最后,求思路指导

第一阶段:

img

img

第二阶段:

img

img
第三阶段:

img

img

#include <stdio.h>
#include <stdlib.h>

// Possible square states.
#define VISIBLE_SAFE 0
#define HIDDEN_SAFE 1
#define HIDDEN_MINE 2

// The size of the starting grid.
#define SIZE 8

// The possible command codes.
#define DETECT_ROW 1
#define DETECT_SQUARE 2
#define REVEAL_CROSS 3
#define GAME_MODE 4
#define FLAG_MINE 5
#define DEFUSE 6

// Add any extra #defines here.

void initialise_field(int minefield[SIZE][SIZE]);
void print_debug_minefield(int minefield[SIZE][SIZE]);

// Place your function prototyes here.

int main(void) {
int minefield[SIZE][SIZE];

initialise_field(minefield);
printf("Welcome to minesweeper!\n");
printf("How many mines? ");

// TODO: Scan in the number of pairs of mines.

printf("Enter pairs:\n");

// TODO: Scan in the pairs of mines and place them on the grid.


printf("Game Started\n");
print_debug_minefield(minefield);


// TODO: Scan in commands to play the game until the game ends.
// A game ends when the player wins, loses, or enters EOF (Ctrl+D).
// You should display the minefield after each command has been processed.


return 0;

}

// Set the entire minefield to HIDDEN_SAFE.
void initialise_field(int minefield[SIZE][SIZE]) {
int i = 0;
while (i < SIZE) {
int j = 0;
while (j < SIZE) {
minefield[i][j] = HIDDEN_SAFE;
j++;
}
i++;
}
}

// Print out the actual values of the minefield.
void print_debug_minefield(int minefield[SIZE][SIZE]) {
int i = 0;
while (i < SIZE) {
int j = 0;
while (j < SIZE) {
printf("%d ", minefield[i][j]);
j++;
}
printf("\n");
i++;
}
}

每个阶段的代码分开

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答

本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。