-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10189.cpp
More file actions
46 lines (46 loc) · 1.04 KB
/
10189.cpp
File metadata and controls
46 lines (46 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
int b[105][105];
void check(int i, int j) {
i++;
j++;
b[i - 1][j - 1]++;
b[i - 1][j]++;
b[i - 1][j + 1]++;
b[i][j - 1]++;
b[i][j + 1]++;
b[i + 1][j - 1]++;
b[i + 1][j]++;
b[i + 1][j + 1]++;
}
int main() {
char a[101][101];
char ch;
int i, j, n, k = 0, m, l;
while (scanf("%d %d", &n, &m)) {
getchar();
if (n == 0 && m == 0) return 0;
memset(b, 0, sizeof(b));
k++;
for (i = 0; i < n; i++) {
gets(a[i]);
for (j = 0; j < m; j++) {
if (a[i][j] == '*') {
check(i, j);
}
}
}
if (k != 1) printf("\n");
printf("Field #%d:\n", k);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
if (a[i][j] != '*')
printf("%d", b[i + 1][j + 1]);
else
printf("*");
}
printf("\n");
}
}
return 0;
}