0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-26 18:32:01 +00:00
OI-codes/Luogu/P2670/P2670.cpp
2021-11-21 19:06:54 +08:00

34 lines
823 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, m;
char g[105][105];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> g[i] + 1;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (g[i][j] != '*') {
int sum = 0;
sum += g[i - 1][j - 1] == '*';
sum += g[i - 1][j] == '*';
sum += g[i - 1][j + 1] == '*';
sum += g[i][j - 1] == '*';
sum += g[i][j + 1] == '*';
sum += g[i + 1][j - 1] == '*';
sum += g[i + 1][j] == '*';
sum += g[i + 1][j + 1] == '*';
cout << sum;
} else {
cout << g[i][j];
}
}
cout << endl;
}
return 0;
}