//迷宫的全部代码
#include <iostream.h>
#include <stdio.h>
#include<stdlib.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef int SElemType;
typedef struct
{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
typedef int PosType;
typedef struct
{
int ord;
PosType seat;
int di;
}SElemType;
//typedef int SElemType;
#include "migong.h"
Status InitStack(SqStack &s)
{
s.base=(SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType));
if (!s.base)
exit(OVERFLOW);
s.top=s.base;
s.stacksize=STACK_INIT_SIZE;
return OK;
}
Status 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(OVERFLOW);
s.top=s.base+s.stacksize;
s.stacksize+=STACKINCREMENT;
}
*s.top++=e;
return OK;
}
Status Pop(SqStack &s,SElemType &e)
{
if(s.top==s.base)
return ERROR;
e=*--s.top;
return OK;
}
Status StackEmpty(SqStack s)
{
if (s.top==s.base)
return TRUE;
else
return FALSE;
}
Status Pass()
{
}
Status FootPrint()
{
}
Status MarkPrint()
{
}
Status NextPos()
{
}
Status MazePath(SElemType maze,PosType start,PosType end)
{
PosType curpos;
PosType curstep;
InitStack(S);
curpos=start;
curstep=1;
SElemType e;
do{
if (Pass(curpos))
{
FootPrint(curpos);
e=(curstep,curpos,1);
Push(S,e);
if(curpos==end)
return (TRUE);
curpos=NextPos(curpos,1);
curstep++;
}
else
{
if (!StackEmpty(S))
{
Pop(S,e);
while (e.di==4&&!StackEmpty(s))
{
MarkPrint(e.seat);
Pop(S,e);
}
if (e.di<4)
{
e.di++;
Push(S.e);
curpos=NextPos(e.seat,e.di);
}
}
}
}
while (!StackEmpty(S));
return (FALSE);
}
不懂的可以Q我:605081231