当前位置:网站首页>顺序队列
顺序队列
2022-08-04 20:42:00 【柯基@】
- 顺序队列定义
typedef struct{
int data[MaxSize]; // MaxSize 是已定义的常量
int front;
int rear;
}SqQueue;
- 初始化
void initQueue(SqQueue &qu){
qu.front=qu.rear=0;
}
- 判断队空
int isEmpty(SqQueue qu){
if(qu.front==qu.rear) //队首,对尾指针重合,则队空
return 1;
else
return 0;
}
- 入队
int enQueue(SqQueue &qu,int x){
if((qu.rear+1)%maxSize==qu.front) //队满,不可进
return 0;
qu.data[qu.rear]=x; //入队两部曲
qu.rear=(qu.rear+1)%maxSize;
return 1;
}
- 出队
int deQueue(SqQueue &qu,int &x){
if(qu.front==qu.rear) //队空,不可出
return 0;
x=qu.data[qu.front]; //出队两部曲
qu.front=(qu.front+1)%maxSize;
return 1;
}
边栏推荐
- STP基本配置及802.1D生成树协议的改进
- C#的Dictionary字典集合按照key键进行升序和降序排列
- Zero-knowledge proof notes - private transaction, pederson, interval proof, proof of ownership
- KubeSphere简介,功能介绍,优势,架构说明及应用场景
- C语言小笔记+题
- Getting Started with Lattice Passwords
- C#移动OA办公系统源码(基于微信企业号)
- 在vs code中进行本地调试和开启本地服务器
- ASP.NET商贸进销存管理系统源码(带数据库文档)源码免费分享
- 某男子因用本地虚拟机做压测,惨遭字节面试官当场嘲笑
猜你喜欢

Desthiobiotin衍生物Desthiobiotin-PEG4-Amine/Alkyne/Azide/DBCO

【debug】postgres数据存储错乱

阿里的arthas使用,入门报错:Unable to attach to 32-bit process running under WOW64

构建Buildroot根文件系统(I.MX6ULL)

Interviewer: How is the expired key in Redis deleted?

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

新式茶饮,卷完水果还能卷什么?

Oreo域名授权验证系统v1.0.6公益开源版本网站源码

Getting Started with Lattice Passwords

Oreo domain name authorization verification system v1.0.6 public open source version website source code
随机推荐
Oreo domain name authorization verification system v1.0.6 public open source version website source code
微信小程序云开发 | 赠、删、改城市名称信息的应用实现
vs Code runs a local web server
【Web漏洞探索】跨站脚本漏洞
【1403. 非递增顺序的最小子序列】
ASP.NET商贸进销存管理系统源码(带数据库文档)源码免费分享
取证程序分类
两种白名单限流方案(redis lua限流,guava方案)
面试官:索引为什么会失效?
【CAS:2306109-91-9 |胺-PEG4-脱硫生物素】价格
【TypeScript】深入学习TypeScript枚举
DICOM医学影像协议
面试官:JVM运行时数据区包含哪几部分?作用是啥?
Chrome安装zotero connector 插件
使用 Allatori 进行 Jar 包混淆
Web3安全风险令人生畏,应该如何应对?
idea源码无法下载
STP基本配置及802.1D生成树协议的改进
Interviewer: How is the expired key in Redis deleted?
win10 uwp 使用 ScaleTransform 放大某个元素