答疑解惑必采纳 2021-07-12 09:19 采纳率: 91.3%
浏览 36
已采纳

用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++;
}
}

  • 写回答

2条回答 默认 最新

  • 答疑解惑必采纳 2021-07-12 09:21
    关注

    每个阶段的代码分开

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已采纳回答 7月13日
  • 修改了问题 7月12日
  • 创建了问题 7月12日

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。