n,m< =100

（注意两个矩阵之间应该有一个空行，由于oj的格式化这里不能显示出来）

0< n,m< =100

#i:”,接下来的n行中，读入的’.'应被该位置周围的地雷数所代替。输出的每两个矩阵必须用一个空行隔开。

1*10 1110 Field #2: **100 33200 1*100

AC代码如下：
#include <iostream> using namespace std; const int N = 110; int n, m; char g[N]
[N]; char a[N][N]; int main() { int count = 0; while (cin >> n >> m, n, m) {
count++; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> g[i][j
]; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (g[i][j] ==
'*') a[i][j] = '*'; else if (g[i][j] == '.') { int cnt = 0; if ( i + 1 <= n && j
<= m && g[i + 1][j] == '*') cnt++; if (i + 1 <= n && j + 1 <= m && g[i + 1][j +
1] == '*') cnt++; if (i + 1 <= n && j - 1 >= 1 && g[i + 1][j - 1] == '*') cnt++;
if (i - 1 >= 1 && j <= m && g[i - 1][j] == '*') cnt++; if (i - 1 >= 1 && j + 1
<= m && g[i - 1][j + 1] == '*') cnt++; if (i - 1 >= 1 && j - 1 >= 1 && g[i - 1][
j- 1] == '*') cnt++; if (i <= n && j + 1 <= m && g[i][j + 1] == '*') cnt++; if (
i<= n && j - 1 >= 1 && g[i][j - 1] == '*') cnt++; a[i][j] = cnt + '0'; } } cout
<< "Field #" << count << ": " << endl; for (int i = 1; i <= n; i++) { for (int j
= 1; j <= m; j++) { cout << a[i][j]; } cout << endl; } cout << endl; } return 0;
}

#include <iostream> using namespace std; const int N = 110; int n, m; char g[N]
[N]; char a[N][N]; int main() { int count = 0; while (cin >> n >> m, n, m) { for
(int i = 0; i <= n + 1; i++) for (int j = 0; j <= m + 1; j++) g[i][j] == '.';
count++; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> g[i][j
]; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (g[i][j] ==
'*') a[i][j] = '*'; else if (g[i][j] == '.') { int cnt = 0; if (g[i + 1][j] ==
'*') cnt++; if (g[i + 1][j + 1] == '*') cnt++; if (g[i + 1][j - 1] == '*') cnt++
; if (g[i - 1][j] == '*') cnt++; if (g[i - 1][j + 1] == '*') cnt++; if (g[i - 1]
[j - 1] == '*') cnt++; if (g[i][j + 1] == '*') cnt++; if (g[i][j - 1] == '*')
cnt++; a[i][j] = cnt + '0'; } } cout << "Field #" << count << ": " << endl; for
(int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cout << a[i][j]; }
cout<< endl; } cout << endl; } return 0; }