2019-07-31 11:11:25
Minesweeper is a venue n rows, m columns character map consisting of;
* ? ? ? ? * ? ? ?
* Indicates which mines? It indicates safety area
Now calculate the required number of mines around each security zone;
Around defined as: regional security position "up", "down", "left", "right", "upper left", "right upper", "lower left", "lower right" eight zones
"?" Shown above a map of the security zone in the fill the number of mines around:
* 2 1 1 2 * 0 1 1
Sample input:
3 3 * ? ? ? ? ? ? * ?
Sample Output
* 1 0 2 2 1 1 * 1
Problem decomposition
Define a two-dimensional character array to store a minefield , then define a two-dimensional array of integers to store the number of each position around the mines.
Minefield input, gets a row can be read, it can be clocked into the character with getchar.
Output array of characters, character by character can be output putchar;