我绝望.我检讨..模拟..
一直pe..提交若干次后才发现是格式里多了个空格.
以后这个pe我是记住了..
#include <iostream>
using namespace std;

int n,m,x,y,u;
char ch[11][11];
bool hash[11][11];
int st[11][11];
void dfs(int x,int y,int step)


{
st[x][y]=step;
hash[x][y]=true;
switch(ch[x][y])

{
case 'N':x--;break;
case 'E':y++;break;
case 'W':y--;break;
case 'S':x++;break;
default:break;
}
if (x<1||y<1||x>n||y>m)

{
cout<<step<<" step(s) to exit"<<endl;
return;
}
if (hash[x][y])

{
cout<<st[x][y]-1<<" step(s) before a loop of "<<step-st[x][y]+1<<" step(s)"<<endl;
return;
}
dfs(x,y,step+1);
}
int main()


{
while(1)

{
cin>>n>>m>>u;
if (n==0&&m==0&&u==0) break;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)

{
cin>>ch[i][j];
hash[i][j]=false;
}
// memset(hash,0,sizeof(hash));
dfs(1,u,1);
}
return 0;
}
