-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path10189-minesweper.c
40 lines (40 loc) · 1017 Bytes
/
10189-minesweper.c
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
#include<stdio.h>
int main()
{
int a,b,i,k=1,j;
char ar[102][102];
while(scanf("%d %d",&a,&b)==2)
{
if(a==0 && b==0)break;
int out[102][102]= {0};
for(i=1; i<=a; i++)
scanf("%s",ar[i]);
for(i=1; i<=a; i++)
for(j=0; j<b; j++)
{
if(ar[i][j]=='*')
{
out[i-1][j]++;
out[i-1][j-1]++;
out[i-1][j+1]++;
out[i][j-1]++;
out[i][j+1]++;
out[i+1][j]++;
out[i+1][j+1]++;
out[i+1][j-1]++;
}
}if(k!=1)printf("\n");
printf("Field #%d:\n",k++);
for(i=1; i<=a; i++)
{
for(j=0; j<b; j++)
{
if(ar[i][j]=='*')
printf("%c",ar[i][j]);
else printf("%d",out[i][j]);
}
printf("\n");
}
}
return 0;
}