[cpp
sqStack.h
#include "selemtype.h"
#define MaxSize 1000
typedef struct
{
SElemType data[MaxSize];
int top;
}Stack;
Status InitStack(Stack &S);
Status DestroyStack(Stack &S);
Status StackEmpty(Stack &S);
Status Push(Stack &S,SElemType &e);
Status Pop(Stack &S,SElemType &e);
[cpp] view plaincopy
sqStack.cpp
#include "sqstack.h"
#include<iostream>
using namespace std;
Status InitStack(Stack &S)
{
S.top = 0 ;
for( int i = 0 ; i < MaxSize ; i++ )
{
S.data[i].di = 0 ;
S.data[i].ord = 0 ;
S.data[i].seat.c = 0;
S.data[i].seat.r = 0;
}
return true;
}
Status DestroyStack(Stack &S)
{
S.top = 0 ;
return true;
}
Status StackEmpty(Stack &S)
{
bool judger = false ;
if(S.top == 0)
judger = true;
return judger;
}
Status Push(Stack &S,SElemType &e)
{
bool judger = false;
if(S.top < MaxSize)
{
S.data[S.top] = e ;
S.top++;
judger = true ;
}
return judger;
}
Status Pop(Stack &S,SElemType &e)
{
bool judger = false ;
if(S.top > 0)
{
S.top--;
e = S.data[S.top] ;
judger = true ;
}
return judger;
}
[cpp]
Mazepath.h
#define N 15
#define M 22
//分割块占总空间比例
#define V 0.4
typedef struct ElemType
{
int x,y;
char c;
}ElemType;
typedef struct MazeType
{
ElemType arr[N][M];
}MazeType;
Status Pass(MazeType &MyMaze, PosType CurPos);
void FootPrint(MazeType &MyMaze, PosType CurPos);
void MarkPrint(MazeType &MyMaze, PosType CurPos);
PosType NextPos(PosType CurPos, int Dir);
Status MazePath(MazeType &maze, PosType start, PosType end);
[cpp]
Mazepath.cpp
/*------------------------------------------------