当前位置:网站首页>链栈的应用
链栈的应用
2022-08-04 20:42:00 【柯基@】
【例】用不带头结点的单链表存储链栈,设计初始化栈、判断栈是否为空、进栈和出栈等相应的算法。
typedef struct LNode{
int data;
struct LNode *next;
}LNode;
//初始化
void initStack(LNode *&lst){
lst=NULL;
}
//判断是否为空
int isEmpty(LNode *lst){
if(lst==NULL)
return 1;
else
return 0;
}
//进栈
void push(LNode *&lst,int x){
LNode *p;
p=(LNode*)malloc(sizeof(LNode));
p->data=x;
p->next=NULL;
//以下为插入操作
p->next=lst;
lst=p;
}
//出栈
void pop(LNode *&lst,int &x){
LNode *p;
if(lst==NULL)
return 0;
p=lst;
x=p->data;
lst=lst->next;
free(p);
return 1;
}
边栏推荐
- Desthiobiotin衍生物Desthiobiotin-PEG4-Amine/Alkyne/Azide/DBCO
- Oreo域名授权验证系统v1.0.6公益开源版本网站源码
- Comic | Two weeks after the boss laid me off, he hired me back and doubled my salary!
- C语言小笔记+题
- 零知识证明——zkSNARK证明体系
- Oreo domain name authorization verification system v1.0.6 public open source version website source code
- WIN10系统如何开启终端
- 关于 SAP 电商云 Spartacus UI SSR 的 state transfer 问题
- Elastic Search 根据匹配分和热度分排序
- 37.轮播图
猜你喜欢

Matlab画图2

面试官:Redis中过期的key是怎么被删除的?
![[Data Mining] Written Exam Questions for Sohu Data Mining Engineers](/img/d9/450eeecd5c7835d40ac38da41fc08e.png)
[Data Mining] Written Exam Questions for Sohu Data Mining Engineers

【CAS:2306109-91-9 |胺-PEG4-脱硫生物素】价格

Zero-knowledge proof notes - private transaction, pederson, interval proof, proof of ownership

After encountering MapStruct, the conversion between PO, DTO and VO objects is no longer handwritten

C#移动OA办公系统源码(基于微信企业号)

使用 Allatori 进行 Jar 包混淆

ts集成和使用

LED的C语言应用程序
随机推荐
微信小程序云开发 | 赠、删、改城市名称信息的应用实现
刷题-洛谷-P1319 压缩技术
Uniapp微信雪糕刺客单页小程序源码
Debug locally and start the local server in vs code
多商户商城系统功能拆解22讲-平台端分销商品
MySQL字段类型
[Academic related] Tsinghua professor persuaded to quit his Ph.D.:I have seen too many doctoral students have mental breakdowns, mental imbalances, physical collapses, and nothing!...
Desthiobiotin衍生物Desthiobiotin-PEG4-Amine/Alkyne/Azide/DBCO
How to carry out AI business diagnosis and quickly identify growth points for cost reduction and efficiency improvement?
SAP ABAP OData 服务如何支持 $select 有选择性地仅读取部分模型字段值试读版
Comic | Two weeks after the boss laid me off, he hired me back and doubled my salary!
五分钟入门文本处理三剑客grep awk sed
vs Code 运行一个本地WEB服务器
二叉树是否对称
刷题-洛谷-P1179 数字统计
手撕SparkSQL五大JOIN的底层机制
MYSQL gets the table name and table comment of the database
KubeSphere简介,功能介绍,优势,架构说明及应用场景
web漏洞扫描器-awvs
How to make good use of builder mode