求助,谁帮我看看
#difine STACK_INIT_SIZE 100
#difine STACKINCREMENT 10
typedef struct
{int x;
int y;
}postype;
typedef struct
{int ord;
postype seat;
int di;
}selemtype;
typedef struct
{selemtype *base;
selemtype *top;
int stacksize;
}sqstack;
sqstack *s;
postype start,end,curpos;
int a[10][10];
start.x=1;
start.y=1;
end.x=8;
end.y=8;
ininarray()
{int i,j;
for(i=1;i<9;i++)
for(j=1;j<9;j++)
if(i==0||i==9||j==0||j==9)a[i][j]=0;
a[1][3]=0;
a[1][7]=0;
a[2][3]=0;
a[2][7]=0;
a[3][5]=0;
a[3][6]=0;
a[4][2]=0;
a[4][3]=0;
a[4][4]=0;
a[5][4]=0;
a[6][2]=0;
a[6][6]=0;
a[7][2]=0;
a[7][3]=0;
a[7][4]=0;
a[7][6]=0;
a[7][7]=0;
a[8][1]=0;
}
initstack()
{s.base=(selemtype*)malloc(STACK_INIT_SIZE*sizeof(selemtype));
if(!s.base)exit(0);
s.top=s.base;
s.stacksize=STACK_INIT_SIZE;
}
push(sqstack *s,selemtype e)
{if(s.top-s.base>=s.stacksize)
{s.base=(selemtype*)realloc(s.base,(s.stacksize+STACKINCREMENT)*sizeof(selemtype);
if(!s.base)exit(0);
s.top=s.base+s.stacksize;
s.stacksize+=STACKINCREMENT;
}
*s.top++=e;
}
pop(sqstack *s,selemtype e)
{if(s.top==s.base)exit(0);
e=*--s.top;
}
stackempty(sqstack s)
{if(s.top==s.base)return 1;
else return 0;
}
nextpos(int i)
{ switch(i)
{
case 1:(e.seat.y)++;break;
case 2:(e.seat.x)--;break;
case 3:(e.seat.y)--;break;
case 4:(e.seat.x)++;break;
default :break;
}
}
footprint(pos i)
{
a[i.x][i.y]=e.dir;
}
mazepath()
{
selemtype e;
initstack();
curpos=start;
curstep=1;
do{
if(pass(curpos))
{
footprint(e.seat);
e=(curstep,curpos,1);
push(s,e);
if(curpos==end)return 1;
curpos=nexrpos(curpos,1);
curstep++;
}
else
{if(!stackempty(s))
{pop(s,e);
while(e.di==4&&!stackempty(s))
{footprint(e.seat);
pop(s,e);
}
if(e.di<4)
{e.di++;
push(s,e);
curpos=nextpos(e.seat,e.di);
}
}
}
}while(!stackempty(s));
return 0;
}
main()
{int i,j;
initarray()
if(mazepath())
for(i=1;i<9:i++)
for(j=1;j<9;j++)
if(a[i][j]==9)printf("(%d,%d)",i,j);
else printf("the mazepath is a impossible problem!");
}