```cpp
if(fx<1 or fy<1 or fx>n or fy>m or a[fx][fy]=='.') continue;
```
为什么会有这么神奇的写法
by 康师傅 @ 2019-04-13 00:15:30
c++11了解一下
by crpboy @ 2019-04-13 07:08:09
你还可以这样
```cpp
and
```
by yu__xuan @ 2019-04-13 08:29:54
@[AFoxOfZzr](/space/show?uid=118086)
您是不是语言选错了呀,
by yu__xuan @ 2019-04-13 08:32:19
@[AFoxOfZzr](/space/show?uid=118086)
```cpp
for(int j=1;i<=m;j++)
```
i?
by yu__xuan @ 2019-04-13 08:47:05
@[AFoxOfZzr](/space/show?uid=118086)
```cpp
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,ans;
char a[10001][10001];
int kx[10]= {0,1,-1,0,0,1,1,-1,-1};
int ky[10]= {0,0,0,1,-1,1,-1,1,-1};
void dfs(int x,int y) {
int fx=0,fy=0;
a[x][y]='.';
for(int i=1; i<=8; i++) {
fx=x+kx[i];
fy=y+ky[i];
if(fx<1||fy<1||fx>n||fy>m||a[fx][fy]=='.') continue;
else {
a[fx][fy]='.';
dfs(fx,fy);
}
}
}
int main() {
scanf("%d%d",&n,&m);
getchar();
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) {
/*cin>>a[i][j];*/a[i][j]=getchar();
}
getchar();
}
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) {
if(a[i][j]=='W') {
ans++;
dfs(i,j);
}
}
}
printf("%d",ans);
return 0;
}
```
改完的代码。。。
by yu__xuan @ 2019-04-13 08:50:24
@[康师傅](/space/show?uid=136822) w
by AFoxOfZzr @ 2019-04-13 09:41:07
@[yu__xuan](/space/show?uid=142110) 谢谢w
by AFoxOfZzr @ 2019-04-13 09:41:26