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 |
Faint...WA ing,附代码,请大家帮忙. Thx#include <iostream> using namespace std; const int size=10; char c[size][size]; int a[size][size]; int row,col,st,steps; int main() { while(cin>>row>>col>>st&&row) { steps=0; memset(c,0,sizeof(c)); memset(a,0,sizeof(a)); for(int i=0;i<row;i++) for(int j=0;j<col;j++) cin>>c[i][j]; int tmprow=0,tmpcol=st-1; char temp; while(!(tmprow<0||tmpcol<0)&&!(a[tmprow][tmpcol])) { steps++; a[tmprow][tmpcol]=steps; temp=c[tmprow][tmpcol]; switch(temp) { case 'N': tmprow--;break; case 'S': tmprow++;break; case 'E': tmpcol++;break; case 'W': tmpcol--;break; } } if(tmprow<0||tmpcol<0||tmprow>=row||tmpcol>=col) cout<<steps<<" step(s) to exit"<<endl; else { cout<<a[tmprow][tmpcol]-1<<" step(s) before a loop of "<<steps-a[tmprow][tmpcol]+1<<" step(s)"<<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