#include<stdio.h>
#include<malloc.h>
#define true 1
#define false 0
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
#define yes 1
#define no 0
typedef int ElemType;
typedef int Status;
typedef struct Node{
ElemType data;
struct Node *next;
}Stack,*LinkStack;
LinkStack InitStack(LinkStack top)
{
top = (LinkStack)malloc(sizeof(Stack));
top->next = NULL;
return top;
}
LinkStack PushLinkStack(LinkStack top,ElemyType e)
{
LinkStack p;
p = (LinkStack)malloc(sizeof(Stack));
p->data = e;
p->next = top->next;
top->next = p;
return top;
}
ElemType PopLinkStack(LinkStack top)
{
LinkStack p;
ElemType e;
if(top->next = NULL)
return false;
else{
p = top->next;
e = p->data;
top->next = p->next;
free(p);
}
return e;
}
数据结构-链栈
最新推荐文章于 2024-06-03 22:50:30 发布