#include<iostream>
#include <cstring>
using namespace std;
const int N = 25;
int w, h;
char mp[N][N];
bool st[N][N];
int startx, starty;
int ans = 1;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
void dfs(int x, int y){
for(int i = 0; i < 4; i++){
int xx = x+dx[i];
int yy = y+dy[i];
if(mp[xx][yy] == '#' || xx < 1 || xx > w || yy < 1 || yy > h || st[xx][yy]) continue;
st[xx][yy] = 1;
ans ++;
dfs(xx, yy);
}
}
int main(){
while(cin >> h >> w){
memset(st, 0, sizeof st);
if(w == 0 && h == 0)break;
for(int i = 1; i <= w; i++){
for(int j = 1; j <= h; j++){
cin >> mp[i][j];
if(mp[i][j] == '@') {
startx = i;
starty = j;
}
}
}
st[startx][starty] = 1;
dfs(startx, starty);
cout << ans << endl;
ans = 1;
memset(mp, 0, sizeof mp);
}
return 0;
}
谁家好人出题行列反着来啊啊啊啊!
真服了
rm -rf /*