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 again !但我的边缘数据都OK<<<<<<<<错,你在哪? 我实在是找不到啊 #include<stdio.h> int main() { int b[100][2],row,col,sta,i,x,y,count,flag=1; char grid[10][12]; while(scanf("%d%d%d",&row,&col,&sta)) { if(row==0&&col==0&&sta==0) break; x=sta-1; y=0; count=0; for(i=0;i<row;i++) scanf("%s",grid[i]); b[count][0]=x;b[count][1]=y; flag=1; while(flag) { count++; switch(grid[y][x]) { case'E':x=x+1;b[count][0]=x;b[count][1]=y;break; case'W':x=x-1;b[count][0]=x;b[count][1]=y;break; case'S':y=y+1;b[count][0]=x;b[count][1]=y;break; case'N':y=y-1;b[count][0]=x;b[count][1]=y;break; } for(i=0;i<count;i++) { if(b[count][0]==b[i][0]&&b[count][1]==b[i][1]) { printf("%d step(s) before a loop of %d step(s)\n",i,count-i); flag=0; break; } } if(x<0||x>=col||y<0||y>=row) { printf("%d step(s) to exeit\n",count); flag=0; } } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator