数据结构 链栈的基本操作
2013-12-10 19:20
134 查看
#include <stdio.h> #define OK 1 #define ERROR 0 #define OVERFLOW -2 typedef int SElemType; typedef struct StackNode { SElemType data; struct StackNode *next; }StackNode, *LinkStackPtr; typedef struct LinkStack { LinkStackPtr top; int count; }LinkStack; int Push(LinkStack &S, SElemType e) { LinkStackPtr s = (LinkStackPtr) malloc(sizeof(StackNode)); s->data = e; s->next = S.top; S.top = s; S.count++; return OK; } int Pop(LinkStack &S, SElemType &e) { LinkStackPtr p; if (stackEmpty(S)) return ERROR; e = S.top ->data ; p = S.top ; S.top = S.top ->next ; free(p); S.count --; return OK; }
相关文章推荐
- 数据结构中栈的链式结构—链栈的基本操作
- 数据结构---链栈的基本操作
- 数据结构的链栈基本操作
- 数据结构系列-链栈的基本操作
- 数据结构-链栈的基本操作
- 数据结构 - C语言版 - 链栈 所有基本操作
- 【数据结构】链栈的基本操作
- 数据结构 - 链栈的基本操作(C语言)
- 数据结构 链栈的基本操作
- 数据结构 - C语言版 - 线性表 所有基本操作
- 链栈的基本操作实现
- 【数据结构】双向链表的基本操作
- 数据结构 P64-65 算法实现 循环队列的创建和基本操作
- 【C++/数据结构】循环链表的基本操作
- 数据结构-链式线性表基本操作实现
- 数据结构 - 串的性质和基本操作(一)
- 【数据结构】双向循环线性表的基本操作--C++/C实现
- C语言-单链表的基本操作-严蔚敏版的数据结构
- 链栈的基本操作
- 【数据结构】串的基本操作