//纯模拟 #include#include using namespace std; struct node { char direction; int step; }; node map[11][11]; int main() { int row,column,enter,step,i,j,v[11][11],x,y; while(scanf("%d%d%d",&row,&column,&enter)&&(row!=0||column!=0||enter!=0)) { memset(v,0,sizeof(v)); getchar(); for(i=1;i<=row;i++) { for(j=1;j<=column;j++) scanf("%c",&map[i][j].direction); getchar(); } x=1; y=enter; step=0; while(0 row||y>column) printf("%d step(s) to exit\n",step); else printf("%d step(s) before a loop of %d step(s)\n",map[x][y].step-1,step-map[x][y].step+1); } }