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 |
C写的,感觉没错误,为啥总WA呀0.0,大神看看#include<stdio.h> #define MAX 20 int main() { char s[MAX][MAX]={0}; int s_1,s_2; //输入的行列 int n,m; //从左边第几个开始出发 int i,j,k,s1,s2,tag; //其他参数 int a[MAX*MAX]; while((scanf("%d%d%d",&s_1,&s_2,&n))!=-1) { fflush(stdin); if(s_1==0&&s_2==0&&n==0) exit(0); for(i=1;i<=s_1;i++) { for(j=1;j<=s_2;j++) scanf("%c",&s[i][j]); fflush(stdin); } s1=1; s2=n; k=0; while(s[s1][s2]!=0) { tag=1; for(m=0;m<k-1;m++) { if(a[k-1]==a[m]) { tag=0; break; } } if(tag==0) { printf("%d step(s) before a loop of %d step(s)\n",m,k-m-1); break; } a[k++]=s1*10+s2; switch(s[s1][s2]) { case 'N':s1--;break; case 'S':s1++;break; case 'E':s2++;break; case 'W':s2--;break; } } a[k]='\0'; if(tag!=0) printf("%d step(s) to exit\n",k); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator