Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:不解啊！！！wa了好几次

Posted by 3013216027 at 2014-07-22 09:14:18 on Problem 2386
In Reply To:不解啊！！！wa了好几次 Posted by:h452422845 at 2014-04-26 20:26:45
```> #include <stdio.h>
> #include <string.h>
> char map[101][101];
> int n,m;
> //int move[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
> void dfs(int x,int y)
> {
>     map[x][y]='.';
>    for(int dx=-1;dx<=1;dx++)
>     for(int dy=-1;dy<=1;dy++)
>    {
>        int nx=x+dx,ny=y+dy;
>        if(0<=nx&&nx<n&&0<=ny&&ny<m&&map[nx][ny]=='W')
>          dfs(nx,ny);
>    }
> }
> int main()
> {
>     int sum=0;
>     memset(map,0,sizeof(map));
>     scanf("%d%d",&n,&m);
>     for(int i=0;i<n;i++)
>         for(int j=0;j<m;j++)
>         scanf("%c",&map[i][j]);//为什么这样的输入不能ac
> //for(int i=0;i<n;i++)
>     //scanf("%s",&map[i]); //改成这样就ac了
>     for(int i=0;i<n;i++)
>     {
>         for(int j=0;j<m;j++)
>     {
>         if(map[i][j]=='W')
>            {
>                dfs(i,j);
>                sum++;
>            }
>     }
>     }
>     printf("%d\n",sum);
>     return 0;
> }

Followed by: