#P361. 【例62.3】 地雷数计算
【例62.3】 地雷数计算
Description
Minesweeper is a classic single-player game. Its essence lies in determining whether unopened cells contain mines based on the numbers shown in opened cells, which indicate the count of mines in surrounding cells.
Given the mine distribution in an minefield, calculate the number of surrounding mines for each non-mine cell.
Note: Each cell has eight surrounding cells: up, down, left, right, upper-left, upper-right, lower-left, and lower-right.
Input Format
First line contains two integers and , representing the number of rows and columns in the minefield (, ).
Next lines, each containing characters, where '' represents a mine and '' represents a non-mine cell. There are no separators between characters.
Output Format
Output lines, each containing characters, describing the entire minefield. If a cell contains a mine, represent it with '', otherwise represent it with the number of surrounding mines. There are no separators between characters.
Sample
3 3
*??
???
?*?*10
221
1*1