#include <stdio.h>
#include <stdlib.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
#define MAX 20
typedef int VertexType;
typedef struct ArcNode//表结点
{
int adjvex;//弧所指向的顶点的位置
struct ArcNode *nextarc;
}ArcNode;
typedef struct VNode//头结点
{
VertexType data;//顶点信息
ArcNode *firstarc;//指向第一条依附该弧的顶点指针
}VNode,*AdjList;
typedef struct
{
AdjList vertices;
int vexnum;//图的**当前**顶点数
}ALGraph;
typedef struct//栈的定义
{
int *base;
int *top;
int stacksize;
}SqStack;
/////////栈的操作函数定义
void initialStack(SqStack *s)
{
s->base=(int *)malloc(STACK_INIT_SIZE*sizeof(int));
if(!s->base) exit(0);
s->top=s->base;
s->stacksize=STACK_INIT_SIZE;
}
void Push(SqStack *s,int e)
{
if(s->top-s->base>=s->stacksize)
{
s->base=(int *)realloc(s->base,(STACK_INIT_SIZE+STACKINCREMENT)*sizeof(int));
if(!s->base) exit(0);
s->top=s->base+s->stacksize;
s->stacksize+=STACKINCREMENT;
}
*(s->top)++=e;
}
void Pop(SqStack *s,int *e)
{
if(s->top==s->base) exit(0);
*e=*--(s->top);
}
void GetTop(SqStack *s,int *e)
{
if(s->top==s->base) exit(0);
*e=*(s->top-1);
}
int StackEmpty(SqStack *s)
{