minesweeper (easy)
Submit solution
Points:
10 (partial)
Time limit:
1.0s
Memory limit:
256M
Authors:
Problem types
Allowed languages
Java 19, Java 8
題目說明
給定一3 x 3陣列,並套用踩地雷規則,輸出地雷與剩餘位置的值為多少
踩地雷規則:
假設一3 x 3棋盤如下
0 | 1 | 2 | |
---|---|---|---|
0 | x | ||
1 | x | ||
2 |
輸入範例
x0000x000
以任一空白格為焦點,若周圍八格有一顆地雷(x),則該格數字加一,若周圍無地雷,則輸出0
套用以上規則,可得知空白格依序為:
0 | 1 | 2 | |
---|---|---|---|
0 | x | 2 | 1 |
1 | 1 | 2 | x |
2 | 0 | 1 | 1 |
輸出範例:
x 2 1
1 2 x
0 1 1
sample input1
xxx00xxxx
sample output1
x x x
4 7 x
x x x
Comments