文档介绍:迷宫及哈希表问题程序代码
#include<>
#define M 4
#define Q 4
#define STACK_INIT_SIZE 30 //存储空间初始量
#define STACK_INCREMENT 10//存储空间初始增量
#include<>
#include<>
#include<>
#define HASHSIZE 10
typedef struct
{ int row;
int col;
int dir;
}elemtype;
typedef struct
{ elemtype *base;
elemtype *top;
int stacksize;
}Sqstack;
int maze[M+2][Q+2];
Sqstack S;
int count=0;
int InitStack(Sqstack S)//初始化栈
{ Sqstack S;
=(elemtype *)malloc(STACK_INIT_SIZE*sizeof(elemtype));
if(!)
exit(0);
=;
=STACK_INIT_SIZE;
return 1;
}//InitStack
int StackEmpty(Sqstack S)
//判断栈是否为空,如果为空返回TRUE,否则返回FALSE
{
if(==)
return 1;
return 0;
}//StackEmpty
int Push(elemtype e)
//插入元素为e的栈顶元素
{
if(->=)
{
=(elemtype*)realloc(,(+STACK_INCREMENT)*sizeof(elemtype));
if(!)
exit(0);
=+;
+=STACK_INCREMENT;
}
*++=e;
return 1;
}//Push
int Pop(elemtype e)
//删除栈顶元素存入e
{
if(==)
return 0;
e=*--;
return 1;
}//Pop
int DestroyStack(Sqstack S)
//销毁栈
{
free();
=;
return 1;
}//DestroyStack
void Init_maze() /*迷宫的初始化*/
{int i,j;
for(i=0;i<M+2;i++)
for(j=0;j<Q+2;j++)
maze[i][j]=1;
printf("plea