-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA10189.cpp
More file actions
33 lines (33 loc) · 832 Bytes
/
UVA10189.cpp
File metadata and controls
33 lines (33 loc) · 832 Bytes
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int n, m, count = 0;
while (scanf("%d %d", &n, &m) != EOF && n) {
while (getchar() != '\n');
if (count) puts("");
char list[110][110];
for (int i = 0; i<n; i++)
fgets(list[i], sizeof(list[i]), stdin);
printf("Field #%d:\n", ++count);
for (int i = 0; i<n; i++) {
for (int j = 0; j<m; j++) {
if (list[i][j] == '*') printf("*");
else {
int out = 0;
if (list[i + 1][j] == '*') out++;
if (list[i + 1][j + 1] == '*') out++;
if (list[i + 1][j - 1] == '*') out++;
if (list[i - 1][j] == '*') out++;
if (list[i - 1][j + 1] == '*') out++;
if (list[i - 1][j - 1] == '*') out++;
if (list[i][j - 1] == '*') out++;
if (list[i][j + 1] == '*') out++;
printf("%d", out);
}
}
puts("");
}
}
}