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<stdio.h> int main() { int i,j,n,m,began,row,line,step=0; char a[20]; int shuju[10][10]; while(1) { scanf("%d %d %d",&n,&m,&began); if(n==0&&m==0&&began==0) break; step=0; getchar(); for(i=0;i<n;i++) { gets(a); for(j=0;j<m;j++) { if(a[j]=='N') shuju[i][j]=-1; else if(a[j]=='E') shuju[i][j]=-2; else if(a[j]=='S') shuju[i][j]=-3; else if(a[j]=='W') shuju[i][j]=-4; } } row=0;line=began-1; while(!(row<0||row>=n||line<0||line>=m||shuju[row][line]>0)) { if(shuju[row][line]==-1) { shuju[row][line]=++step; row--; } if(shuju[row][line]==-2) { shuju[row][line]=++step; line++; } if(shuju[row][line]==-3) { shuju[row][line]=++step; row++; } if(shuju[row][line]==-4) { shuju[row][line]=++step; line--; } } if(shuju[row][line]>0) printf("%d step(s) before a loop of %d step(s)\n",shuju[row][line]-1,step-shuju[row][line]+1); else printf("%d step(s) to exit\n",step); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator