-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbomb.c
More file actions
65 lines (55 loc) · 1.35 KB
/
Copy pathbomb.c
File metadata and controls
65 lines (55 loc) · 1.35 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
int main()
{
char a[20][21];
int i,j,sum,map=0,p,q,x,y,n,m;
scanf("%d %d", &n, &m);
for(i=0; i<=n-1; i++)
scanf("%s", a[i]);
for(i=0; i<=n-1; i++)
{
for(j=0; j<=m-1; j++)
{
if(a[i][j] == '.')
{
sum = 0;
x=i; y=j;
while(a[x][y] != '#')
{
if(a[x][y] == 'G')
sum++;
x--;
}
x=i; y=j;
while(a[x][y] != '#')
{
if(a[x][y] == 'G')
sum++;
x++;
}
x=i; y=j;
while(a[x][y] != '#')
{
if(a[x][y] == 'G')
sum++;
y--;
}
x=i; y=j;
while(a[x][y] != '#')
{
if(a[x][y] == 'G')
sum++;
y++;
}
if(sum>map)
{
map = sum;
p=i; q=j;
}
}
}
}
printf("将炸弹放置在(%d,%d),最多可以消灭%d个敌人\n", p, q, map);
getchar();getchar();
return 0;
}