-
Notifications
You must be signed in to change notification settings - Fork 0
/
10279.cpp
81 lines (60 loc) · 1.58 KB
/
10279.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<stdio.h>
/* Mine Sweeper - 10279 */
main(){
int i,j,c,n,cont,flag;
char aux[10][11],grid[12][13];
scanf("%d",&c);
for(;c>0;c--){
flag = 0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s",aux[i]);
for(i=0;i<=n+1;i++)
for(j=0;j<=n+1;j++)
grid[i][j] = '\0';
for(i=0;i<n;i++)
for(j=0;j<n;j++)
grid[i+1][j+1] = aux[i][j];
for(i=0;i<n;i++)
scanf("%s",aux[i]);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(aux[i][j] == 'x')
{
cont = 0;
if(grid[i][j]=='*')
cont++;
if(grid[i][j+1]=='*')
cont++;
if(grid[i][j+2]=='*')
cont++;
if(grid[i+1][j]=='*')
cont++;
if(grid[i+1][j+2]=='*')
cont++;
if(grid[i+2][j]=='*')
cont++;
if(grid[i+2][j+1]=='*')
cont++;
if(grid[i+2][j+2]=='*')
cont++;
if(grid[i+1][j+1] == '*')
flag = 1;
else
aux[i][j] = cont+'0';
}
if(flag)
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(grid[i+1][j+1] == '*')
aux[i][j] = '*';
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
putchar(aux[i][j]);
putchar('\n');
}
if(c!=1)
putchar('\n');
}
}