




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#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
- 高校科研合同模板(3篇)
- 高速公路护栏板施工合同(3篇)
- 高炮广告拆除施工合同(3篇)
- 安徽招聘考试试题及答案
- 安徽农商银行笔试题目及答案
- 安定协管员招聘面试题及答案
- 股东间公司治理信息保密及责任分配协议
- 地下室车库顶板行车、堆载、回顶方案
- 幼儿园礼仪小天使《借物品》教学课件
- 2024年河南鹤壁市鹤山区姬家山产业园政府专职消防员招聘笔试参考题库附带答案详解
- BCG 中国合成生物学产业白皮书2024
- 三年级数学倍的认识 省赛一等奖
- 大脑动脉血栓形成引起的脑梗死的护理查房
- 人教版小学英语所有语法及人教版小学英语语法大全
- 儿童膳食管理课件
- 《高血压疾病知识》课件
- 村卫生室医保管理制度
- 第一课 社会主义从空想到科学、从理论到实践的发展 思维导图+必背知识点填空+同步练习(含答案)
评论
0/150
提交评论