
我都还没调用这个函数怎么就报错呢
代码如下:
#include
#include
using namespace std;
const int M=0,N=0;
int maze[M+2][N+2];
stack s;
typedef struct
{
int incX,incY;}direction;
direction direct[4];
typedef struct
{
int x,y;int di;}box;
bool findpath(int maze[M+2][N+2],direction direct[],stack &s)
{
box temp;int line,col;maze[1][1]=-1;temp.x=1;temp.y=1;temp.di=-1;s.push(temp);while(!s.empty()){temp=s.pop();x=temp.x;y=temp.y;di=temp.di+1;while(di<4){line = x+direct[di].incX;col=y+ direct[di].incY;if(maze[line][col]==0){temp={x,y,di};s.push(temp);x=line;y=col; maze[line][col]=-1;if(x==M&&y==N) return true;else di=0;}else di++;}}return false;}
void outnop()
{
cout<<"请输入你想要的出口的位置坐标: "<<endl;cin>>M>>N;cout<<"出口设置成功!"<<endl;}
void creatmaze()
{
cout<<"请创建迷宫(0表示通路,1表示障碍,请勿忘记边界!): "<<endl;for(int i=0;i<N+2;i++){for(int j=0;j<M+2;j++){cin>>maze[i][j];}}cout<<"创建成功!"<<endl;}
void dispaly()
{
for(int i=0;i<N+2;i++){for(int j=0;j<M+2;j++){cout<<maze[i][j]<<" ";}cout<<endl;}}
int main()
{
outnop();creatmaze();display();return 0;}
-
push函数调用错误,与push函数定义的参数类型不一致
stack存储的是int类型,你push的是box类型,不一致