problem link 

minesweeper uva 10189 solution

Technique to solve this problem

As you may have already noticed, each square may have at most 8 adjacent squares. Let us suppose a mine is at (i,j)  location. its all adjacent blocs would be

minesweeperTo check all 8 adjacent blocks we will use two helper arrays  int dirx[8] = { -1, -1, -1, 0, 0, 1, 1, 1 } and int diry[8] = { -1, 0, 1, -1, 1, -1, 0, 1 }.

  • Find each mine and increments count of all valid adjacent squares blocks.