涓昏璇ラ琚垜鎯沖鏉備簡錛屼竴寮濮嬩互涓烘槸涓嶅悓褰㈢姸鐨勪釜鏁幫紝鍒頒笉鍚屼釜鏁扮殑涓暟錛屾渶鍚庛傘傘傚師鏉ユ槸闂湁澶氬皯鍧楋紒
鍏釜if錛岃屼笉鏄痠f-else if!
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char map[105][105];
bool used[105][105];
bool dep[200];
int m,n;
bool check(int a,int b){
return a > 0 && a <= m && b > 0 && b <= n && !used[a][b] && map[a][b];
}
void init(){
memset(map,0,sizeof(map));
memset(used,0,sizeof(used));
memset(dep,0,sizeof(dep));
}
int dfs(int a,int b){
int res=1;
if(check(a+1,b)){
used[a+1][b] = true;
res += dfs(a+1,b);
}
if(check(a-1,b)){
used[a-1][b] = true;
res += dfs(a-1,b);
}
if(check(a,b-1)){
used[a][b-1] = true;
res += dfs(a,b-1);
}
if(check(a,b+1)){
used[a][b+1] = true;
res += dfs(a,b+1);
}
if(check(a-1,b-1)){
used[a-1][b-1] = true;
res += dfs(a-1,b-1);
}
if(check(a+1,b-1)){
used[a+1][b-1] = true;
res += dfs(a+1,b-1);
}
if(check(a-1,b+1)){
used[a-1][b+1] = true;
res += dfs(a-1,b+1);
}
if(check(a+1,b+1)){
used[a+1][b+1] = true;
res += dfs(a+1,b+1);
}
return res;
}
int main(){
while(scanf("%d%d",&m,&n)!=EOF && m != 0){
char al;
char line[200];
int c=0;
init();
for(int i = 1; i <= m ;i++){
scanf("%s",line);
for(int j = 1; j <= n; j++){
if(line[j-1] == '@')map[i][j] = true;
}
}
for(int i = 1; i <= m ;i++)
for(int j = 1; j <= n; j++){
if(check(i,j)){
//cout << i <<' '<<j <<endl;
used[i][j] = true;
int t=dfs(i,j);
dep[t] = true;
c++;
}
}
/*for(int i = 1; i <= 199; i++){
if(dep[i]) c++;
}*/
printf("%d\n",c);
}
}

]]>