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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

单链表实验报告.docx

1、单链表实验报告数据结构实验报告姓名章杰学号2012211496专业班级通信工程12-1指导教师实验时间2013/4/22实验地点四号机房(实验名称)1. 实验目标a) 熟练掌握线性表的链式存储结构。b) 熟练掌握单链表的有关算法设计。c) 根据具体问题的需要,设计出合理的表示数据的顺序结构,并设计相关算法。2. 实验内容和要求本次实验中的链表结构指带头结点的单链表;单链表结构和运算定义,算法的实现以库文件方式实现,不得在测试主程序中直接实现;实验程序有较好可读性,各运算和变量的命名直观易懂,符合软件工程要求;程序有适当的注释。3. 数据结构设计#includeiostream.htypedef

2、 int elementtype;typedef struct snode elementtype data; struct snode* next;node; class listpublic: list(); / list(); int length() const; int get_element(const int i,elementtype &x)const; node* locate(const elementtype x)const; int Insert(const int i,const elementtype x); void insert(const elementtyp

3、e x); int delete_element(const int i); node* get_head()return head; void creat_R(); void creat_H(); void print(); void list:interset (list a,list b,list& c); bool list:delete1(); void list:destroy(); void list:outnode(list &B,node* &q); void list:combine (list &A,list &B);private: int count; node* h

4、ead;list:list() head=new node; head-next=NULL; count=0;int list:length()const node* p=head-next; int n=0; while(p!=NULL) n+; p=p-next; return n;int list:get_element(const int i,elementtype &x)const node* p=head-next; int j=1; while(p!=NULL&j!=i) p=p-next;j+; if(p=NULL) return 0; x=p-data; return 1;n

5、ode* list:locate(const elementtype x)const node* p=head-next; while(p!=NULL) if(p-data=x) return p; else p=p-next; return NULL;int list:Insert(const int i,const elementtype x) node* p=head; int j=0; while(j!=i-1&p!=NULL) p=p-next;j+; if(icount+1) return 0; node* s=new node; s-data=x; s-next=p-next;

6、p-next=s; count+; return 1;int list:delete_element(const int i) node* p=head; int j=0; while(j!=i-1&p!=NULL) p=p-next;j+; if(icount) return 0; node* u=p-next; p-next=u-next; delete u; count-; return 1;void list:creat_R() elementtype x; cout请输入数据元素:(以9999结束)x; node* rear=head; while(x!=9999) count+;

7、node* s=new node; s-data=x; rear-next=s; rear=s; rear-next=NULL; cinx; void list:creat_H() elementtype x; cout请输入数据元素:(以9999结束)x; while(x!=9999) count+; node* s=new node; s-data=x; s-next=head-next; head-next=s; cinx; void list:print() node* p=head-next; int j=1; while(j=count) coutdatanext;j+; cout

8、next; while(p-data next; node*u=new node; u-data=p-data; p-data =x; u-next=p-next ; p-next =u; count+;void list:interset (list a,list b,list& c) node*pa,*pb,*rc,*u; rc=c.get_head (); pa=a.get_head ()-next ; pb=b.get_head ()-next ; while( pa!=NULL& pb!=NULL) if(pa-data data ) pa=pa-next ; else if ( p

9、a-data pb-data ) pb=pb-next ; else u=new node; u-data =pa-data ; rc-next=u ; rc=u; c.count +; pa=pa-next ; pb=pb-next ; rc-next =NULL;bool list:delete1() node*p=head-next; if(p=NULL) return false; while (p-next !=NULL) if(p-data =p-next-data ) node*u=new node; u=p-next ; p-next =u-next ; delete u; c

10、ount-; else p=p-next ; return true; void list:destroy() node *p, *u; p=head-next; while(p) u=p-next; delete p; p=u; cout单链表已销毁next; B.head-next=q-next;void list:combine (list &A,list &B) node *p,*q,*m; p=A.head-next; while(B.length()!=0) outnode(B,q); if(A.head-next-data =q-data) A.head -next =q; q-

11、next =p; else while(p-next!=NULL) if(q-data p-data & q-data next-data) m=p-next; p-next=q; q-next=m; break; else if(q-datap-next-data) p=p-next; if(p-next=NULL) p-next=q; break; B.head=NULL;4. 算法设计(除书上给出的基本运算(这部分不必给出设计思想),其它实验内容要给出算法设计思想)5. 运行和测试6. 总结和心得 本次实验的内容较上次多,难度也明显增加了,所幸的是,自己课下空余时间有提前编写,才得以按时上交,由此可见,实验并不是课上那两三个小时的事情,更多的是课下我们下的功夫!虽然实验难度加大了,但是通过和一些同学的讨论,还是得以顺利解决了!看着自己的劳动获得了收获,真的很有成就感!再接再厉!7. 附录(源代码清单。纸质报告不做要求。电子报告,可直接附源文件,删除编译生成的所有文件) 源代码见文件夹:linkedList

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

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