Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
ac#include <iostream> using namespace std; char a[101][101]; int b[8][2]={1,0,-1,0,0,1,0,-1,1,1,1,-1,-1,1,-1,-1}; void dfs(int x,int y) { a[x][y]='*'; for(int k=0;k<8;k++) if(a[x+b[k][0]][y+b[k][1]]=='@') dfs(x+b[k][0],y+b[k][1]); } int main(int argc, char *argv[]) { int m,n; while(cin>>m>>n,m,n) { int i,j,k,s=0; for(i=0;i<m;i++) for(j=0;j<n;j++) cin>>a[i][j]; for(i=0;i<m;i++) for(j=0;j<n;j++) if(a[i][j]=='@'){s++;dfs(i,j);} cout<<s<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator