当前位置:网站首页>栈和队列a
栈和队列a
2022-04-23 12:12:00 【Yuerya.】
一.栈
1.定义(top指向最后一个元素的角标)
#define Max 100
Typedef struct stack{
SElemType data[Max] //或*data;
int top;
int stackSize;
}sqStack;
2.初始化
int InitSqStack(sqStack *LS,int max){
LS->data=(SElemType*)malloc(max*(SElemType));
if(LS->data==NULL) { printf("申请失败\n"); exit(0); }
LS->top=-1;
LS->stackSize=max;
return 1;
}
3.判断为空
int EmptyStack(sqStack S){
if(S.top==-1) return 1;
else return 0;
}
4.获得栈顶
int GetTopSqStack(sqStack S,SElemType *e){
if(S.top==-1) return 0;
*e=S.data[S.top];
return 1;
}
5.求长度
int lengthsqStack(sqStack S){
if(S.top==-1) return 0;
return S.top+1;
}
6.进栈
int PushsqStack(sqStack *S,SElemType e){
if(S->top+1==S->stackSize) //如果栈满
版权声明
本文为[Yuerya.]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_62032391/article/details/124359263
边栏推荐
- Optimize connections using connection groups (IM 6)
- Lesson 26 static member functions of classes
- CGC: contractual graph clustering for community detection and tracking
- 异步时钟亚稳态 的解决方案——多bit信号
- Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?
- The fourth chapter is to enable the filling object of IM and enable ADO for im column storage (IM 4.8)
- [web daily practice] eight color puzzle (float)
- On using go language to create websocket service
- Debug Jest test cases in VSCode, debug Jest test cases in VSCode, middle note basedir=$(dirname "$" (echo "$0" sed -e -e, s, \ \, / "-e").
- 画结果图推荐网址
猜你喜欢
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
激活函数之relu函数
Force buckle - 1137 Nth teponacci number
初探 Lambda Powertools TypeScript
PSCP basic usage
消息队列概述
九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
Idea code formatting plug-in save actions
编程辅助工具推荐:图片工具snipaste
AI 视频云 VS 窄带高清,谁是视频时代的宠儿
随机推荐
IDEA 代码质量规范插件SonarLint
What is a gateway
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
一个平面设计师的异想世界|ONES 人物
电脑系统卡如何解决?
Chapter 4 is a tutorial on forced filling of in memory objects with IM enabled filling objects (IM 4.7)
Sofa weekly | excellent Committee of the year, contributor of this week, QA of this week
PSCP basic usage
Windows11 安装MySQL服务 提示:Install/Remove of the Service Denied
软件测试基础DAY2-用例执行
Chapter 5 optimizing queries using in memory expressions (IM 5.1)
The maximum number of remote desktop servers has been exceeded
AI video cloud vs narrowband HD, who is the darling of the video era
对称加密、证书加密
第二十三课 临时对象
软银愿景基金进军Web3安全行业 领投CertiK 6000万美元新一轮投资
Resolution due to AMD not found_ ags_ x64. DLL, unable to continue code execution. Reinstallation of the program may solve this problem, Forza horizon 5
Tips for installing MySQL service in windows11: Install / Remove of the Service denied
User interface and im expression (IM 5.6)
欣旺达宣布电池产品涨价 此前获“蔚小理”投资超10亿