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

## 求大牛解释啊。。。。。。。。奇怪地A掉 花括号的问题！

Posted by starkerry at 2011-02-22 21:43:10 on Problem 3051
```#include <iostream>
#include <cstring>
#include <algorithm>
#define max 7000
int da[max];
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
char grid[max][max];
int m,n,num=0;
void dfs(int x,int y)
{
if(grid[x][y]=='.')
return ;
grid[x][y]='.';
dfs(x-1,y);
dfs(x+1,y);
dfs(x,y+1);
dfs(x,y-1);
da[num]++;
}
int main ()
{
int i,j,sum=0;
while (scanf ("%d%d",&m,&n)==2)
memset(grid,'.',max * max * sizeof(char));
memset(da,0,sizeof(da));
for(i=1;i<=n;i++)
{
for (j=1;j<=m;j++)
grid[i][j]=getchar();
if (i!=n)
getchar();
}
for (i=1;i<=n;i++)
{
for (j=1;j<=m;j++)
if(grid[i][j]=='*')
{
dfs(i,j);
num++;
}
}
sort(&da[0],&da[max],cmp);
printf("%d\n",da[0]);
return 0;
}

Followed by: