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 |
为什么WA啊???#include<iostream> #include<string.h> #include<stdlib.h> using namespace std; #define MAX 30 int W,H; char Graph[MAX][MAX]; int result=0; int direction[4][2]={{0,1},{0,-1},{-1,0},{1,0}}; void DFS(int p,int q) { int i; if(p>=0 &&p<=W-1 &&q>=0 &&q<=H-1 &&Graph[p][q]=='.') { result++; Graph[p][q]='#'; } else { return ; } for(i=0;i<4;i++) { int x=p+direction[i][0]; int y=q+direction[i][1]; DFS(x,y); } } int main() { int i,j,p,q; while(cin>>H>>W) { if(H==0 &&W ==0) break; for(i=0;i<W;i++) { for(j=0;j<H;j++) { cin>>Graph[i][j]; if(Graph[i][j]=='@') { p=i; q=j; Graph[i][j]='.'; } } } DFS(p,q); cout<<result<<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