递归算法入门
#include <stdio.h>
char places[22][22];
int steps;
void slu(int x,int y)
{
if(places[y][x]=='.'||places[y][x]=='@')
{
steps++;
places[y][x]='#';
slu(x+1,y);
slu(x-1,y);
slu(x,y+1);
slu(x,y-1);
}
}
int main()
{
int x,y,i,j;
scanf("%d %d",&x,&y);
while(x)
{
steps=0;
for(i=1;i<=y;i++)
scanf("%s",&places[i][1]);
for(i=0;i<x+2;i++)
places[0][i]=places[y+1][i]='#';
for(i=0;i<y+2;i++)
places[i][0]=places[i][x+1]='#';
for(i=1;i<=y;i++)
for(j=1;j<=x;j++)
if(places[i][j]=='@')
slu(j,i);
printf("%d\n",steps);
scanf("%d %d",&x,&y);
}
return 0;
}