杭电ACM-1241 Oil Deposits

#include
#define N 150
#define M 150
using namespace std;
char oil[N][M];
void dfs(int x,int y)
{
oil[x][y]='*';
int i,j,n,m;
for(i=-1;i<=1;i++)
{
for(j=-1;j<=1;j++)
{
int n=x+i,m=y+j;
if(n>=0 && n=0 && m dfs(n,m);
}
}
}
int main()
{
while(1)
{
int num=0,N1,M1;
cin>>N1>>M1;
if(N1==0)
return 0;
for(int i=0;i for(int j=0;j cin>>oil[i][j];
for(int x1=0;x1 {
for(int y1=0;y1 {
if(oil[x1][y1]=='@')
{
dfs(x1,y1);
num++;
}
}
}
cout<
}


}

你可能感兴趣的:(杭电ACM-1241 Oil Deposits)