当前位置:网站首页>栈和队列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
边栏推荐
- How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
- Tensorflow common functions
- C set Logo Icon and shortcut icon
- 抓包整理————tcp 协议[八]
- On using go language to create websocket service
- IDEA 代码质量规范插件SonarLint
- Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
- 【Redis 系列】redis 学习十三,Redis 常问简单面试题
- Tan Xiang, CEO of Kechuang · Pera software: the essence of zero trust is digital security. To B should also deeply study the user's mind
- Windows2008系统如何切换PHP版本
猜你喜欢
Database design of forum system
Tan Xiang, CEO of Kechuang · Pera software: the essence of zero trust is digital security. To B should also deeply study the user's mind
Introduction to metalama 4 Use fabric to manipulate items or namespaces
SQL 练习(一)
程序员如何用130行代码敲定核酸统计
Windows11 安装MySQL服务 提示:Install/Remove of the Service Denied
Database design of simple voting system
【Redis 系列】redis 学习十三,Redis 常问简单面试题
The database navigator uses the default MySQL connection prompt: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä’ is unrecognized or repres
Outsourcing for five years, abandoned
随机推荐
科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
什么是网关
Running error: unable to find or load the main class com xxx. Application
Sigmoid function of activation function
同态加密技术学习
Siri gave the most embarrassing social death moment of the year
第四章 为物化视图启用和禁用IM列存储(IM 4.6)
How the database fills in IM expressions (IM 5.4)
Fabric 1.0源代码分析(33) Peer #peer channel命令及子命令实现
对称加密、证书加密
运行报错:找不到或无法加载主类 com.xxx.Application
第二十五课 类的静态成员变量
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
Nativeformysql connects to MySQL 8 prompt: 1251 - client does not support authentication protocol
1.Electron开发环境搭建
The fourth chapter is to enable the filling object of IM and enable ADO for im column storage (IM 4.8)
Database design of forum system
Idea code quality specification plug-in sonarlint
一个平面设计师的异想世界|ONES 人物
Force buckle - 70 climb stairs