找出炸弹放在哪里消灭的敌人最多
#include<iostream>
using namespace std;
char a[20][20];
struct note {
int x;
int y;
};
int getnum(int i,int j){
int p=i, q=j, sum = 0;
//向下统计可以消灭的敌人数(炸弹不能穿墙)
while (a[p][q] != '#') {
if (a[p][q] == 'G')
sum++;
p++;
}
//向上统计可以消灭的敌人数(炸弹不能穿墙)
p = i; q = j;
while (a[p][q] != '#') {
if (a[p][q] == 'G')
sum++;
p--;
}
//向左统计可以消灭的敌人数(炸弹不能穿墙)
p = i; q = j;
while (a[p][q] != '#') {
if (a[p][q] == 'G')
sum++;
q--;
}
//向右统计可以消灭的敌人数(炸弹不能穿墙)
p = i; q = j;
while (a[p][q] != '#') {
if (a[p][q] == 'G')
sum++;
q++;
}
return sum;
}
//起点开始四周扩展