商品货架管理——C实现

商品货架管理——C实现

ID:44345794

大小:104.66 KB

页数:6页

时间:2019-10-21

商品货架管理——C实现_第1页
商品货架管理——C实现_第2页
商品货架管理——C实现_第3页
商品货架管理——C实现_第4页
商品货架管理——C实现_第5页
资源描述:

《商品货架管理——C实现》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、//head.h(头文件)〃定义一个队列structQueue{int*Qlist;intmaxsize;intrear,front;};〃初始化〃清空队列〃判队空〃判队满〃插入新元素进队〃按大小顺序排队〃岀队列〃定义一个栈voidInitQueue(Queue&QL,constintms);voidClearQueue(Queue&QL);intQueueEmpty(Queue&QL);intQueueFullfQueue&QL);boollnsertQueue(Queue&QL,constint&item);voidOrderQueue(Queue&QL);intDeQueue(Queu

2、e&QL);structstack{int*Slist;inttop;intMaxsize;};〃栈初始化〃判栈空〃栈满〃清空栈〃新元素推进栈〃出栈〃输出栈屮元素voidlnitstack(stack&SL,constintMS);boolStackempty(stack&SL);boolStackfull(stack&SL);voidClearstack(stack&SL);intPushfstack&SL,int&item);intPop(stack&SL);voidTraverstack(stack&SL);//achieve,h(实现文件)#include#in

3、clude#include"head.h"〃初始化队列voidInitQueue(Queue&QL,constintms){QL.QIist=newint[ms];if(IQLQIist){cerr«”给队列分配内存失败vvendl;exit(l);}〃各项值,初始化〃清空队列〃判空QL.rear=0;QL.front=0;QL.maxsize=ms;}voidClearQueue(Queue&QL){QL.front=QL.rear=0;}intQueueEmpty(Queue&QL){returnQL.rear==QL.front;}intQueueFull(Queu

4、e&QL){return(QL.rear+1)%QL.maxsizebooIInsertQueue(Queue&QL,constint&item){if(QueueFull(QL)){cerr«"Queueisfull"«endl;=QL.front;}//判满〃插入元素进队exit(l);}讦(QL.rearvQL.maxsize){QL.QIist[QL.rear]=item;QL.rear=(QL.rear+1)%QL.maxsize;}〃尾指针不能超过maxsizereturntrue;}voidOrderQueue(Queue&QL){讦(QueueEmpty(QL)){cout«

5、"Queueisemptynow”«endl;exit(l);}inti,j,item;for(i=0;i

6、化〃判空〃判满〃清空栈〃元素进栈〃元素出栈〃输出栈QL.front=(QL.front+1)%QL.maxsize;returntemp;}voidlnitstack(stack&SL,constintMS){SL.Slist=newint[MS];if(!SL.SIist){cout«"给栈分配内存失败。"«endl;exit(l);}SL.Maxsize=MS;SL.top=-1;}boolStackempty(stack&SL){returnSL.top==-1;}boolStackfull(stack&SL){returnSL.top==SL.Maxsize;}voidClearst

7、ack(stack&SL){SL.top=-1;}intPush(stack&SL,int&item){if(Stackfull(SL))returnfalse;SL.top++;SL.SIist[SL.top]=item;returnSL.SIist[SL.top);}intPop(stack&SL){if(Stackempty(SL))returnfalse;returnSL.SIist[SL.top-]

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。