voidInitBoard(char board[ROWS][COLS], int rows, int cols, charset); voidDisplayBoard(char board[ROWS][COLS], int row, int col); voidSetMine(char board[ROWS][COLS], int row, int col); voidFindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col);
voidInitBoard(char board[ROWS][COLS], int rows, int cols, charset) { for (int i = 0; i < rows; ++i) for (int j = 0; j < cols; ++j) board[i][j] = set; }
voidDisplayBoard(char board[ROWS][COLS], int row, int col) { printf("----- 扫雷 -----\n"); for (int j = 0; j <= col; ++j) printf("%d ", j); printf("\n");
for (int i = 1; i <= row; ++i) { printf("%d ", i); for (int j = 1; j <= col; ++j) printf("%c ", board[i][j]); printf("\n"); } }
voidSetMine(char board[ROWS][COLS], int row, int col) { int count = EASY_COUNT; while (count > 0) { int x = rand() % row + 1; int y = rand() % col + 1; if (board[x][y] == '0') { board[x][y] = '1'; --count; } } }