在移动模块(void mo)碰墙就停,不知其因,求大佬解QAQ
#include<bits/stdc++.h>
using namespace std;
char m[12][12];
int x1,Y1,z1,x2,y2,z2,ans;
int f[500000];
void mo(int &x,int &y,int &z){
if (z==0){
if (m[x-1][y]=='*') z++;
else x--;
}else if (z==1){
if (m[x][y+1]=='*') z++;
else y++;
}else if (z==2){
if (m[x+1][y]=='*') z++;
else x++;
}else{
if (m[x][y-1]=='*') z=0;
else y--;
}
return;
}
int main ()
{
z1=z2=0;
for(int i=0;i<12;i++)
m[0][i]=m[11][i]=m[i][0]=m[i][11]='*';
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cin>>m[i][j];
if(m[i][j]=='C'){
x1=i;Y1=j;
}
if(m[i][j]=='F'){
x2=i;y2=j;
}
}
}
int tz;
while(1){
tz=z1*100000+z2*10000*(x1-1)*1000+(x2-1)*100+(Y1-1)*10+y2-1;
if(f[tz]){
cout<<0;
return 0;
}
f[tz]=1;
mo(x1,Y1,z1);
mo(x2,y2,z2);
ans++;
if(x1==x2&&Y1==y2){
cout<<ans;
return 0;
}
}
return 0;
}