文章目录
一、堆栈的链式存储实现
1.定义及存储结构
栈的链式存储结构实际上就是一个单链表,叫做链栈。插入和删除的操作只能在链栈的栈顶进行
typedef struct SNode *Stack;
struct SNode{
ElementType Data;
struct SNode *Next;
};
2.相关操作
(1)堆栈初始化
Stack CreateStack()
{
Stack S;
S = (Stack)malloc(sizeof(struct SNode));
S -> Next = NULL;
return S;
}
(2)判断堆栈是否为空
int IsEmpty(Stac