



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* Copyright (C), 2001-2011, Huawei Tech. Co., Ltd. * File Name : Version : Author : Created : 2012/03/12 Last Modified : Description : Function List : History : 1.Date : 2012/03/12 Author : Modification: Created file*/#include #define MAXSIZE 50struct strqueue int queueMAXSIZE;int head; /* 队头 */int tail; /* 队尾 */int num; /* 队元素个数 */;bool initqueue(struct strqueue *s)if (!s)return 0;for (int i = 0; i queuei = 0;s-head = -1;s-tail = -1;s-num = 0;return 1;bool enqueue(struct strqueue *s, int x) /* 进队列,返回0表示失败,返回1表示成功 */if (!s)return 0;if (s-num = MAXSIZE)return 0;if (s-head = -1 | s-tail = -1) s-head = 0;s-tail = 0;s-queues-tail = x; /*赋值*/s-num = 1;return 1;s-tail = (s-tail + 1) % MAXSIZE;s-queues-tail = x;s-num+;return 1;bool dequeue(struct strqueue *s, int *x) /* 出队列,返回0表示失败,返回1表示成功 */if (!s | !x)return 0;if (s-num = 0)return 0;*x = s-queues-head; /*赋值*/s-queues-head = 0;s-head = (s-head + 1) % MAXSIZE;/*从对头出队列*/s-num-;if (s-num = 0) s-head = -1;s-tail = -1;return 1;int gethead(struct strqueue *s) /* 获得队列头数值 */if (!s)return -1;if (s-num = 0)return -1;int head = 0;head = s-queues-head;return head;int gettail(struct strqueue *s) /* 获得队列尾数值 */if (!s)return 0;int tail = 0;if (s-num = 0)return -1;tail = s-queues-tail;return tail;int getqueuelenth(struct strqueue *s) /* 获得队列长度 */if (!s)return 0;int lenth = 0;lenth = s-num;return lenth;bool search(struct strqueue *s, int x) /* 在队列中查找x是否存在,如果存在返回1,否则返回0 */if (!s)return 0;int headTemp = s-head;int tailTemp = s-tail;if (s-num = MAXSIZE) for (int i = 0; i queuei)return 1;else while (headTemp != tailTemp) if (x = s-queueheadTemp)return 1;headTemp = (headTemp + 1) % MAXSIZE;return 0;int main()struct strqueue queue = NULL,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年无人机驾驶员职业技能考核试卷及答案(无人机操作规范与要求)
- 宫腔粘连考试试题及答案
- 设备人员面试题目及答案
- 飞机训练考试题及答案
- 2025年CAAC执照理论复习考试总题库及答案
- 高利贷借款合同模板全套(3篇)
- 房屋买卖双方签订的带抵押的正式协议
- 出纳岗位安全责任聘用合同
- 创新型农业技术研发成果转化合作补充合同
- 个体户食品加工厂员工劳动合同范本
- JGT366-2012 外墙保温用锚栓
- 《动物比较生理学》课件
- 火龙罐综合灸疗法
- 化学锚栓承载力计算
- 肺部感染性疾病课件
- 医院健康体检表
- 肌肉工作原理
- 液体外渗的处理ppt
- 2016火力发电机组及蒸汽动力设备水汽质量
- 市政排水管网施工方案
- 2023年6月浙江省大学英语三级考试真题试卷
评论
0/150
提交评论