using System; class Program { const char BOMB = '*'; const char BLANK = '.'; static bool CheckBomb(char [,] m, int r, int c) { if((r < 0) || (c < 0)) return false; if((r >= m.GetLength(0)) || (c >= m.GetLength(1))) return false; return (m[r,c] == BOMB); } static int CountBombs(char [,] m, int r, int c) { int count = 0; for(int i=-1; i<=1; i++) for(int j=-1; j<=1; j++) if(((i!=0) || (j!=0)) && CheckBomb(m,r + i,c + j)) count++; return count; } static void PrintEmptyMap(char [,] m) { for(int r=0; r < m.GetLength(0); r++) { for(int c=0; c < m.GetLength(1); c++) Console.Write(m[r,c]); Console.WriteLine(); } } static void PrintFullMap(char [,] m) { for(int r=0; r < m.GetLength(0); r++) { for(int c=0; c < m.GetLength(1); c++) if(CheckBomb(m,r,c)) Console.Write('*'); else Console.Write(CountBombs(m,r,c)); Console.WriteLine(); } } public static void Main(string[] args) { char [,] map = { {'.','.','.','.','.','.'}, {'.','.','*','.','.','.'}, {'.','.','.','.','.','.'}, {'.','*','.','.','.','.'}, {'.','*','.','.','.','.'}, {'.','.','.','.','.','.'}, {'.','.','.','.','.','*'}, {'.','.','.','.','.','.'}, {'.','.','.','.','*','.'}, {'.','.','.','.','.','.'}, }; PrintEmptyMap(map); Console.WriteLine("----------------"); PrintFullMap(map); Console.ReadLine(); } }