数据结构实验报告 堆栈和队列(6)

2021-02-21 18:46

int main()

{int i,m,x,e,f;

linkquene<int> a,b;

cout<<"请输入要产生随机数的个数";

cin>>x;

srand(time(NULL));

cout<<"产生的随机数为:";

for(i=0;i<x;i++)

{m=rand()%100;

cout<<m<<" ";

if(m%2==0)a.pushtail(m);

else b.pushtail(m);}

cout<<endl;

cout<<"成对的奇数和偶数分别为"<<endl;

while(a.popfront(e)&&b.popfront(f))

{cout<<f<<" "<<e<<" "<<endl;}

return 0;

}

3题:

#include<iostream.h>

#include<assert.h>

template<class t1>

struct stacknode{

t1 data;

stacknode *next;};

template<class t1>

class linkstack{

stacknode<t1> *top;

unsigned height;

public:

linkstack();

~linkstack()

{clear();}

void clear();

void push(t1 &x);

bool pop(t1 &x);

bool isempty()

{return(height==0)?true:false;}

};

template<class t1>

linkstack<t1>::linkstack()

{height=0;

top=NULL;}


数据结构实验报告 堆栈和队列(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:《1.4形象的运动动画

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: