堆栈的单链表实现
来源:互联网 发布:量子网络代替互联网 编辑:程序博客网 时间:2024/06/05 18:59
#include <stdio.h>#include <malloc.h>#define ElementType int/*堆栈的链式存储实现*/ typedef struct SNode *Stack;struct SNode{ ElementType Data; struct SNode *Next;}; Stack CreateStack(){ //构造一个堆栈的头结点,返回指针 Stack S; S=(Stack)malloc(sizeof( struct SNode)); S->Next=NULL; return S;}int IsEmpty(Stack S){ //堆栈为空返回1,否则返回0 return (S->Next==NULL);}void Push(ElementType item,Stack S){ struct SNode *TmpCell; TmpCell=(Stack)malloc(sizeof(struct SNode)); TmpCell->Data=item; TmpCell->Next=S->Next; S->Next=TmpCell; } ElementType Pop(Stack S) { struct SNode *FirstCell; ElementType TopElem; if(IsEmpty(S)) { printf("stack is empty."); return NULL; }else{ FirstCell=S->Next; S->Next=FirstCell->Next; TopElem=FirstCell->Data; free(FirstCell); return TopElem; } } int main() { return 0; }
阅读全文
0 0
- 堆栈的单链表实现
- 堆栈的C实现
- 堆栈数据结构的实现~
- 链式实现的堆栈
- 堆栈,队列的实现
- 堆栈的c++实现
- SPFA的堆栈实现
- 堆栈的实现
- 堆栈的简单实现
- VB堆栈的实现
- 数据结构--堆栈的实现
- 堆栈的数组实现
- 堆栈的实现
- 链式堆栈的实现
- 堆栈的实现
- 堆栈的实现
- 堆栈的实现
- 堆栈的实现
- mysql在mac安装有ln: /usr/bin/mysql: Operation not permitted问题
- 13、Chrome 开发者工具
- Codeforces Round #446 (Div. 2)
- NSF Route
- 初识hibernate框架
- 堆栈的单链表实现
- 什么是Java匿名内部类
- flask:小知识点总结
- scanf 和cin 的区别
- freeline入门防踩坑
- py2exe 2.7 将引用matplotlib库的程序转成exe的setup.py 的编写
- Spring使用tx标签配置拦截器动态为指定方法添加事务
- 深度学习和机器学习的相关资料
- 转载:Greenplum负载管理之Resource Queue