ImageVerifierCode 换一换
格式:DOCX , 页数:14 ,大小:17.51KB ,
资源ID:6070695      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6070695.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数构复习程序.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

数构复习程序.docx

1、数构复习程序TemplateVoid Bitree:preorder(binode*bt)top=-1;While(bt!=null|top!=-1)while(bt!=null)coutdata;S+top=bt;Bt=bt-lchild;If(top!=-1)bt=stop-;Bt=bt-rchild;TemplateVoid bitree:inorder(binode*bt)top=-1;While(bt!=null|top!=-1)while(bt!=null)s+top=bt;Bt=bt-lchild;If(top!=-1)coutdata;Bt=Stop-;Coutdata;Bt=

2、bt-rchild;TemplateVoid bitree:postorder(binode*bt)top!=-1;While(bt!=null|top!=-1)while(bt!=null)top+;stop.ptr=bt;Stop.flag=1;Bt=bt-lchild;while(top!=-1&stop.flag=2)bt=stop-.ptr;Coutdata;If(top!=-1)stop.flag=2;Bt=stop.ptr-rchild;TemplateVoid count(binode*root)if(root!=null)Count(root-lchild);Count+;C

3、ount(root-rchild);Int level(binode*bt,datatype x,int h)int l;If(bt=null)return 0;Else if(bt-data=x)return h;Elsel=level(bt-lchild,x,h+1);If(l!=0)return (l);Else return(level(bt-rchild,x,h+1);)TemplateVoid preorderprint(binode*rootIf(root!=null)If(!root-lchild&!root-rchild)countdata;Preorder(root-lch

4、ild);Preorder(root-rchild);TemplateInt depth(binode*root)if(root=null)Return 0;Elsehl=depth(bt-lchild);Hr=depth(bt-rchild);Return max(hl,hr)+1;TemplateVoid exchange(binode*bt)if(root!=null)exchange(root-lchild);Exchange(root-rchild);Root-lchildrchild;Int find(int a,int n)for(i-0;in;i+)If(ai=k) break

5、;Return I;Void selectsort(int r,int n)for(i=0;in;i+)index=i;For(j=i+1;jn;j+)If(rindexrj)Index=j;If(index!=i)Rirj;Void max_nmax(int a,int n, int&nmax,int &max)if(a0=ai)max=a0;nmax=ai;Else(max=a1;nmax=a0;)For(i=2;i=max)Nmax=max;Max=ai;Else if(ai=nmax)Nmax=ai;Cout”最大值为:”max”次最大值为:”maxendl;TemplateSeqli

6、st:seqlist(datatype a,int n)if(nmaxsize) throw”参数非法”;For(i=0;in;i+)datai=ai;Length=n;TemplateDatatype seqlist:get(int i)if(ilength)Throw”参数非法”;Else return datai-1;TemplateDatatype seqlist:locate(datatype x)if(i=0;ilength;i+)If(datai=x);return i+1;Return 0;TemplateVoid seqlist:insert(int I,datatype x

7、)if(length=maxsize)throw “上溢”;If(ilength+1)Throw “位置非法”;For(j=length;j=I;j-)dataj=dataj-1;Datai-1=x;Length+;Templatedelete seqlist:delete(int i)if (length=0)Throw”下溢”;If(ilength)throw”位置非法”;X=datai-1;For(j=i;j=length;j+)Dataj-1=dataj;Length-;Return x;TemplateVoid seqlist:printlist()for(i=0;i=length;

8、i+)Coutdatai;Template Void linklist:printlist()p=first-next;While(p!=null)coutdata;p=p-next;TemplateInt linklist:length()p=first-next;count=0;While(p!=null)p=p-next;Count+;Return count;TemplateDatatype linklist:get(int i)p=first-next;Count=1;While(p!=null&countnext;Count+;If(p=null)Throw “位置”;Else r

9、eturn p-data;Template Datatype linklist:ger(int i)p=first-next;Count=1;While(p!=null&countnext;Count+;If(p=null) throw”位置非法”;Else return p-data;TemplateInt linklist:locate(datatype x)p=first-next;Count=1;While(p!=null)if(p-data)=xReturn count;P=p-next;Count+;return 0;Template Void linklist:insert(in

10、t i,datatype x)p=first;count=0;While(p!=null&countnext;Count+;If(p=null)throw“位置非法”;Else s =new node;s -next= p -next;p-next=s;templatelinklist:linklist()First=new node;First-next=null;TemplateLinklist:linklist(datatype a,int n)first=new node;First-next=null;For(i=0;in;i+)s=new node;s-data=ai;s-next

11、=first-next;first-next=s;templatelinklist(datatype a,int n)First=new nodedatatype;R=first;For(i=0;in;i+)s=new node;s-data=ai;r-next=s;r=s;r-next=null;templatedatatype linklist:delete(int i)P=first;Count=0;While(p!=null&countnext;Count+;If(p=null|p-next=null)Throw”位置”;ElseQ=p-next;x=q-data;p-next=q-n

12、ext;delete q;return x;TemplateLinklist:linklist()while(first!=null)q=first;First=first-next;Delete q;TemplateVoid seqstack:pushif(top=stacksize-1)Throw”上溢”;Data+top=x;TemplateDatatype seqstack:pop()if(top=-1)throw “下溢”;X=datatop-;Return x;TemplateVoid linkstack:pushdatatype x)s=new node ;S-data=x;s-

13、next=top;top=s;templatedatatype linkstack:pop()if(top=-1)throw“下溢”;X=top-data;P=top;top=top-next;Delete p;Return x;TemplateVoid cirqueue:enqueuer(datatype x)if(rear+1)%queuesize=front)throw “上溢”;Rear=(rear+1)%queuesize;Datarear=x;TemplateDatatype cirqueue:getqueue()If(rear=front)throw”下溢”;i=(front+1

14、)%queuesize;Return datai;TemplateDatatype cirqueue:dequeuer()If(rear=front)throw “下溢”;Front=(front+1)%queuesize;Return datafront;Templateclass datatypeLinkqueue:linkqueue()s=new queue;s-next=null;front rear=s;TemplateVoid linkqueue:enqueuer(datatype x)s=new node;s-data=x;s-next=null;rear-next=s;rear

15、=s;TemplateDatatype linkqueue:dequeuer()if(rear=front) throw”下溢”;P=front-next;X=p-data;Front-next=p-next;If(p-next=null)Rear=front;Delete p;Return x;TemplateVoid bitree:preorder(binode*bt)if(bt=null)return;Elsecoutdata;Preorder(bt-lchild);Preorder(bt-rchild);TemplateVoid bitree:inorder(binode*bt)If(

16、nt=null)return;ElseInorder(bt-lchild);Coutdata;Inorder(bt-rchild);TemplateVoid bitree:postorder(binode*bt)if(bt=null) return ;ElsePostorder(bt-lchild);Postorder(bt-rchild);Coutdata;TemplateVoid bitree:levelorder()Front=rear=-1;If(root=null)return;Q+rear=root;While(front!=rear)q=q+front;Coutdata;If(q

17、-lchild!=null)Q+rear=q-lchild;If(q-rchild!=null)Q+rear=q-rchid;TemplateBinode*bitree:creat(binode*bt)cinch;If(ch=”#”)bt=null;ElseBt=new node;Bt-data=ch;Bt-lchild=creat(bt-lchild);Bt-rchild=creat(nt-rchild);return bt;TemplateVoid bitree:release(binode*bt)if(bt!=null)release(bt-lchild);Release(bt-rchi

18、ld);Delete bt;TemplateVoid bitree:preorder(binode*bt)top=-1;While(bt!=null|top!=-1)while(bt!=null)coutdata;S+top=bt;Bt=bt-lchild;If(top!=-1)bt=stop-;Bt=bt-rchild;TemplateVoid bitree:inorder(binode*bt)top=-1;While(bt!=null|top!=-1)while(Bt!=null)s+top=bt;Bt=bt-lchild;If(top!=-1)bt=stop-;Coutdata;Bt=b

19、t-rchild;TemplateVoid bitree:postorder(binode*bt)top=-1;While(bt!=null|top!=-1)while(bt!=null)top+;stop.ptr=bt;stop.flag=1;bt=bt-lchild;While(top!=-1&stop.flag=1)bt=stop-.ptr;Coutdata;If(rtop!=-1)stop-.flag=2;Bt=stop.ptr-rchild;我看见3名身着黑衣的年轻枪手进入音乐厅,其中一个枪手向人群开枪,他们的腿部,肩膀,后背不断中枪,人们像多米诺古牌一样倒下,当至少20-25个人被打倒躺在地板上,他们以行刑姿态对伤者,装死者残忍地补枪,全程一言不发,音乐厅陷入绝望的尖叫声中。我全身颤抖地等待他们耗尽子弹再次上膛,然后逃跑。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1