当时年轻不懂事,这题XJBD了,现在改回来555。。。2016/3/1
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
using namespace std;
const int N = 100;
const int INF = 1000000;
char Map[N][N];
int n, m;
int dir[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
void dfs(int x, int y)
{
for(int i = 0; i < 8; i ++)
{
int xx = x + dir[i][0];
int yy = y + dir[i][1];
if(xx >= 0 && xx < m && yy >= 0 && yy < n && Map[xx][yy] == '@')
{
Map[xx][yy] = '*';
dfs(xx, yy);
}
}
}
int main()
{
// freopen("in.txt", "r", stdin);
int ans;
while(~scanf("%d%d", &m, &n))
{
if(m == 0 && n == 0) break;
ans = 0;
for(int i = 0; i < m; i ++)
for(int j = 0; j < n; j ++)
cin >> Map[i][j];
for(int i = 0; i < m; i ++)
for(int j = 0; j < n; j ++)
{
if(Map[i][j] == '@')
{
ans ++;
dfs(i, j);
}
}
printf("%d\n", ans);
}
}