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 lfydzh at 2013-02-03 14:49:21 on Problem 1562
In Reply To:递归加深搜,测试案例能过,就是WA,大牛帮看看呗~^ ^ Posted by:a65982021 at 2012-08-01 09:32:28
```> #include<iostream>
> using namespace std;
> char map[200][200];
> int count;
> int m,n;
> void dfs(int i,int j)
> {
> 	if(map[i][j]=='*'||i<0||j<0||i>m||j>n)
> 		return;
> 	map[i][j]='*';
> 	dfs(i-1,j-1);
> 	dfs(i-1,j);
> 	dfs(i-1,j+1);
> 	dfs(i,j-1);
> 	dfs(i,j+1);
> 	dfs(i+1,j-1);
> 	dfs(i+1,j);
> 	dfs(i+1,j+1);
> }
> int main()
> {
>
> 	int i,j;
> 	while(scanf("%d%d",&m,&n)&&m!=0)
> 	{
> 		count=0;
> 		while(getchar()==' ');
> 		memset(map,'*',sizeof(map));
> 		for(i=0;i<m;i++)
> 			scanf("%s",&map[i]);
> 			for(i=0;i<m;i++)
> 				for(j=0;j<n;j++)
> 				{
> 					if(map[i][j]=='@')
> 					{
> 						dfs(i,j);
> 					count++;
> 					}
> 				}
> 				printf("%d\n",count);
> 	}
> 	return 1;
> }
```

Followed by: