/********************************************************************* Makes a "beginner" level gameboard which is 10 x 10 and has 10 mines. It starts out with all tiles marked as "covered" ************************************************************************/ void Minesweeper::Beginner() { setBoardSize(10, 10); int mines = 0; while (mines < 10) { /******************************************************************* Loops through the array and places either a mine or an empty cell based on output from RNG ********************************************************************/ for (int r = 0; r < 10; ++r) { for (int c = 0; c < 10; ++c) { for (int idx = 0; idx < r*c; ++idx) { if ((1 + (rand() % 10)) == 1) { setBoard(getMine()); } else { setBoard(getBlank()); } } } } } }
int main() { int Case; scanf("%d", &Case); char touch[12][12] = {}; for (int k = 0; k < Case; k++) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { getchar(); for (int j = 1; j <= n; j++) map[i][j] = getchar(); } bool isTouch = false; for (int i = 1; i <= n; i++) { getchar(); for (int j = 1; j <= n; j++) { if ((touch[i][j] = getchar()) == 'x') if (map[i][j] == '*') isTouch = true; } } if (k) putchar('\n'); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (isTouch&&map[i][j] == '*') putchar('*'); else if (touch[i][j] == 'x') putchar('0' + getMine(i, j)); else putchar('.'); } putchar('\n'); } //init for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) map[i][j] = NULL; } return 0; }