



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/第一个头文件:Seqstack.h#ifndef SEQSTACK_H#define SEQSTACK_H#include using namespace std;const int maxsize=100;template class Seqstacktemplate friend ostream &operator(ostream &,const Seqstack &);public:Seqstack();Seqstack(T a,int n);void push(T i);T pop();Seqstack()private:T datamaxsize;int top;template ostream &operator(ostream &os,const Seqstack &s)for(int i=s.top;i=0;i-)oss.datait;osendl;return os;template Seqstack:Seqstack()top=-1;template Seqstack:Seqstack(T a,int n)top=-1;for(int i=0;in;i+)top+;datai=ai;cout栈的数据初始状态为:n;template void Seqstack:push(T i)if(topmaxsize-1)cout数组溢出!n;top+;datatop=i;template T Seqstack:pop()if(top=-1)cout数组已空!n;int x=datatop;top-;return x;#endif/第二个头文件:Linkqueue.h#ifndef LINKQUEUE_H#define LINKQUEUE_H#include using namespace std;const int queuesize=100;template class Linkqueuepublic:Linkqueue();void entry(T i);T out();int getf();Linkqueue()private:int first;int rear;T dataqueuesize;template Linkqueue:Linkqueue()first=rear=0;template void Linkqueue:entry(T i)if(rear+1)%queuesize=first)cout数组溢出!n;rear=(rear+1)%queuesize;datarear=i;template T Linkqueue:out()if(first=rear)cout数组溢出!n;/这里有个问题,我要再调试看看,先注释掉first=(first+1)%queuesize;return datafirst;template int Linkqueue:getf()return first;#endif/第三个头文件:Function.h#ifndef FUNCTION_H#define FUNTION_H#include #include Linkqueue.h#include Seqstack.husing namespace std;template void fun(Seqstack &s,Linkqueue &l,int &n)for(int i=0;in;i+)l.entry(s.pop();/栈内元素全部出栈 &入队for(int i=0;in;i+)if(l.getf()%2=0)l.entry(l.out();/偶数号先出队&入队else s.push(l.out();/奇数号入栈for(int i=0;i(n/2);i+)l.entry(s.pop();/栈内元素全部出栈&入队for(int i=0;i(n/2);i+)s.push(l.out();/队列前一半偶数号全部出队&入栈for(int i=0;i(n/2);i+)l.entry(s.pop();/栈内元素全部出栈&入队for(int i=0;in;i+)s.push(l.out();/队列所以元素出对&全部入栈cout栈经排序后状态为:n;#endif/主源文件;#include #include Function.husing namespace std;int main(void)int a16=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年中国药典试题及答案
- 2025年中级会计必考试题及答案
- 2025年矿山无人作业技术智能化矿山应急救援报告
- 金融科技与财富管理:2025年财富管理行业风险管理创新模式研究
- 2025年在线艺术拍卖平台艺术品市场供需关系研究报告
- 2025年成人教育线上学习模式创新对教育公平性的影响研究
- 标准编制协议书
- 树苗赔偿协议书
- 校园路演协议书
- 校车免责协议书
- 2025版土鸡蛋购销合同范本
- DMO合成及提纯工艺原理32课件
- 分娩知识的课件
- 基于物联网的地质勘察数据实时传输与管理研究-洞察及研究
- 文化遗产活化路径-第2篇-洞察及研究
- 休闲食品行业2025年发展预测:竞争格局与消费趋势研究报告
- 隧道开挖作业台车计算书
- 煤气作业安全技术实际操作考试标准
- 三年级上人文与社会教案
- (高清版)JGJ123-2012既有建筑地基基础加固技术规范
- 室内装饰施工组织设计方案
评论
0/150
提交评论