0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-05 15:18:47 +00:00
OI-codes/Luogu/P2670/P2670.cpp

34 lines
823 B
C++
Raw Normal View History

#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;
}