Algorithm of 10189 - Minesweeper

Problem Description Link
Algorithm:
In this problem if you compare with "." and increase the adjacent value it is more time consume and get garbage value when row=0 or row=n
 in this case no have 8 adjacent value.
 so you can compare with "*" and generate another 2D value array that contain only value.
 if get "*" in input array then increase the all adjacent value and store that value in value array.
After generating the all value check from input array if character is "*" then print the "*" otherwise print from value array for this position.
image

Solution of 10189 - Minesweeper

Problem Description
source:https://uva.onlinejudge.org/external/101/10189.html

Have you ever played Minesweeper? It’s a cute little game which comes within a certain Operating System which name we can’t really remember. Well, the goal of the game is to find where are all the mines within a M × N field. To help you, the game shows a number in a square which tells you how many mines there are adjacent to that square. For instance, supose the following 4 × 4 field with 2 mines (which are represented by an ‘*’ character): 

*... 
.... 
.*.. 
.... 
If we would represent the same field placing the hint numbers described above, we would end up
with:
*100 
2210 
1*10 
1110
As you may have already noticed, each square may have at most 8 adjacent squares.


image