-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy path10189.cpp
49 lines (41 loc) · 977 Bytes
/
10189.cpp
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
47
48
49
#include <iostream>
using namespace std;
int main (void) {
char field[102][102];
int x, y;
char c;
int counter = 0;
int pos[][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
while (cin >> x >> y) {
if (x == 0 && y == 0) break;
for (int i = 0; i < 102; i++)
for (int j = 0; j < 102; j++)
field[i][j] = '0';
for (int i = 1; i <= x; i++) {
for (int j = 1; j <= y; j++) {
cin >> c;
if (c == '*') field[i][j] = c;
}
}
for (int i = 1; i <= x; i++) {
for (int j = 1; j <= y; j++) {
if (field[i][j] == '*') {
for (int k = 0; k < 8; k++) {
if (field[i + pos[k][0]][j + pos[k][1]] != '*')
field[i + pos[k][0]][j + pos[k][1]] += 1;
}
}
}
}
if (counter > 0) cout << endl;
++counter;
cout << "Field #" << counter << ":" << endl;
for (int i = 1; i <= x; i++) {
for (int j = 1; j <= y; j++) {
cout << field[i][j];
}
cout << endl;
}
}
return 0;
}