




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include #include #include constintQueueNum=10; constintQueuePre=-1; constintERROR=0; constintOK=1; constintTimePiece=1; typedefintElemType; /headdefine. /*/ classQueue_c ElemTypeQQueueNum; intfront,rear; public: /basicinformationoftheclassQueue_c: Queue_c(); intqFull(); intqEmpty(); intqEnQueue(ElemTypee); ElemTypeqDeQueue(); intqGetNumber(); intqGetElem(int); intqShowQueue(); /otherfunctions: ElemTypeqGetFrontElem()if(qEmpty()coutERROR!endl;returnERROR;returnQfront; /intqGetFront()if(qEmpty()coutERROR!endl;returnERROR;returnfront; /ElemTypeqGetRearElem()if(qEmpty()coutERROR!endl;returnERROR;returnQ(rear-1+QueueNum)%QueueNum; /intqGetRear()if(qEmpty()coutERROR!endl;returnERROR;return(rear-1+QueueNum)%QueueNum; /intqShowAll(); intqDec() if(qEmpty()coutERROR!endl;returnERROR;/endif Qfront-=TimePiece; returnOK; /intqXChange(int); ; /=DefineofClassQueue_c= /= classWork_c Queue_cbuf; public: intwCPU(); /ElemTypewScan(int&t); intwMakeP(); intwShowBUF()returnbuf.qShowQueue(); intwInBUF(inti)returnbuf.qEnQueue(i); ; /=DefineofClassWork_c= /= /*=main=* *=proc=*/ voidmain() Work_cw; inti; /w.wInBUF(5); /w.wInBUF(3); /w.wInBUF(1); clrscr(); charflag=y; for(i=0;i10;i+) /w.buf.qShowQueue(); w.wMakeP(); w.wCPU(); w.wShowBUF(); if(9=i) coutAreyouwanttocontinue?y/nflag; if(n=flag)break;elsei=0; clrscr(); /endif /endfor /*=END=* *=main=*/ /*ClassQueue_c*/ /=Queue_c= Queue_c:Queue_c() inti; for(i=0;iQueueNum;i+)Qi=QueuePre; rear=0; front=0; /=qFull= intQueue_c:qFull() if(rear+1)%QueueNum=front) /coutQueueisfullendl; returnOK; elsereturnERROR; /=qEmpty= intQueue_c:qEmpty() if(rear=front) /coutQueueisEmptyendl; returnOK; /endif elsereturnERROR; /=qEnQueue=intQueue_c:qEnQueue(ElemTypee) if(qFull()returnERROR; Qrear=e; rear=(rear+1)%QueueNum; returnOK; /=qDeQueue= ElemTypeQueue_c:qDeQueue() ElemTypee; if(qEmpty()returnERROR; e=Qfront; Qfront=QueuePre; front=(front+1)%QueueNum; returne; /=qGetNumber= intQueue_c:qGetNumber() inti; i=(rear-front+QueueNum)%QueueNum); returni; /=qGetElem= ElemTypeQueue_c:qGetElem(inti) if(qEmpty()coutERROR!qGetNumber()-1) coutERROR!thereisnoi,ornoiinQueuenowendl; returnERROR; returnQ(front+i)%QueueNum; /=qShowQueue= intQueue_c:qShowQueue() inti; if(qEmpty()returnERROR; for(i=front;i!=rear%QueueNum;i=(i+1)%QueueNum) coutQi; /endfor coutendl; returnOK; /=qShowAll= /*intQueue_c:qShowAll() inti; for(i=0;iQueueNum;i+)coutQi; coutendl; returnOK; */ /*intQueue_c:qXChange(inti) ElemTypet; if(1=qGetNumber()returnOK; if(qEmpty()coutERROR!qGetNumber()-1) coutERROR!thereisnoi,ornoiinQueuenow0)buf.qEnQueue(temp); returnOK; /=wScan= /ElemTypeWork_c:wScan(int&t) / /inti,m=12; /ElemTypetemp; /for(i=0;ibuf.qGetNumber();i+) / /temp=buf.qGetElem(i); /if(tempm)m=temp;t=i;/endif /endfor /if(mbuf.qGetFrontElem()returnERROR;/如果是负数的话在这里就被拦下来了,所以,传出出去的m不可能
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025历年导游证考试真题及答案
- 2025科一科四考试真题及答案
- 2025监理考试真题及答案
- 安徽建筑安全员考试试题及答案
- 代持房屋协议书6篇
- 本科《学前教育科研方法》期末考试试题及答案
- 多语言平行语料库构建方法-洞察与解读
- 渔船智能调度系统-洞察与解读
- 2025年《汽车维修工》考试练习题及参考答案
- 营养干预情绪改善-洞察与解读
- 计算机网络基础题库及答案
- 三菱汽车销售团队建设培训课件
- 建筑工地钢筋工安全培训教育试卷
- 清远清城区事业单位考试真题2022
- 中美关系新时代
- GB/T 17622-2008带电作业用绝缘手套
- 部编版六年级语文上册-第三单元习作:-让生活更美好课件
- 耳鼻喉头颈外科考试题库及答案
- 六年级上册科学课件-3.23《传动的齿轮》 l 粤教版(共25张PPT)
- 播音主持自我介绍范文八篇
- 材料分析测试技术 第2版 周玉 课后答案1-4章.khda
评论
0/150
提交评论