342. Minesweeper Numbers
MediumGrid
Replace each . with the number of mines (*) in its 8 neighbours. Mines stay *.
Input format
Line 1: r c Next r lines: the board
Output format
The numbered board.
Example 1
Input
3 4 *... ..*. ....
Output
*211 12*1 0111
Example 2
Input
1 1 .
Output
0
Constraints
1 ≤ r, c ≤ 100
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…