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 |
贴贴挫代码#include<iostream> #include <cstring> using namespace std; char map[105][105]; int ss[105][105]; int DFS(int i,int j) { if(map[i][j]=='#')return 0; map[i][j]='#'; ss[i][j]=DFS(i+1,j)+DFS(i-1,j)+DFS(i,j+1)+DFS(i,j-1)+1; return ss[i][j]; } int main() { int row,col; while(cin>>col>>row && col && row) { memset(map,'#',sizeof(map)); memset(ss,0,sizeof(ss)); int si,sj; for(int i=1;i<=row;++i) { for(int j=1;j<=col;++j) { cin>>map[i][j]; if(map[i][j]=='@')si=i,sj=j; } } cout<<DFS(si,sj)<<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