c++数据结构顺序表、单链表、查找的代码.doc

c++数据结构顺序表、单链表、查找的代码.doc

ID:57586367

大小:48.00 KB

页数:7页

时间:2020-08-27

c++数据结构顺序表、单链表、查找的代码.doc_第1页
c++数据结构顺序表、单链表、查找的代码.doc_第2页
c++数据结构顺序表、单链表、查找的代码.doc_第3页
c++数据结构顺序表、单链表、查找的代码.doc_第4页
c++数据结构顺序表、单链表、查找的代码.doc_第5页
资源描述:

《c++数据结构顺序表、单链表、查找的代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、顺序表#includeusingnamespacestd;templatevoidins_sq_LList(T*v,intm,int*n,inti,Tb){intk;if(*n==m){cout<<"overflow"<*n)i=*n+1;if(i<1)i=1;for(k=*n;k>=i;k--)v[k]=v[k-1];v[i-1]=b;*n=*n+1;return;}#includeusingnamespacestd;templatec

2、lasssq_LList{private:intmm;intnn;T*v;public:sq_LList(){mm=0;nn=0;return;}sq_LList(int);voidprt_sq_LList();intflag_sq_LList();voidins_sq_LList(int,T);voiddel_sq_LList(int);};templatesq_LList(T)::sq_LList(intm){mm=m;v=newT[mm];nn=0;return;}templatevoidsq_LList::

3、prt_sq_LList(){inti;cout<<"nn="<voidlinked_LList::ins_linked_LList(Tx,Tb){node*p,*q;p=newnode;p->d=b;if(head==null){head=p;p->next=null;return;}if(head->d==x){p->next=head;head=p;return;}q=head;while

4、((q->next!=NULL)&&(((q->next)->d)!=x))q=q->next;p->next=q->next;q->next=p;return;}linked_Llist.h#includeusingnamespacestd;templatestructnode{Td;node*next:};templateclasslinked_LList{private:node*head:public:linked_LList();voidprt_linked_LList();voidi

5、ns_linked_LList(T,T);intdel_linked_LList(T);};templatelinked_LList::linked_LList(){head=NULL;return;}templatevoidlinked_LList::prt_linked_LList(){node*p;p=head;if(p==NULL){cout<<"空链表!"<d<next;}while(p!=NULL);return;}#

6、includeusingnamespacestd;templatestructnode{Td;node*next:};//定义线性链表类templateclasslinked_LList{private:node*head:public:linked_LList();voidprt_linked_LList();voidins_linked_LList(T,T);intdel_linked_LList(T);};//建立空链表templatelinked_LList::li

7、nked_LList(){head=NULL;return;}//扫描输出链表中的元素templatevoidlinked_LList::prt_linked_LList(){node*p;p=head;if(p==NULL){cout<<"空链表!"<d<next;}while(p!=NULL);return;}templatevoidlinked_LList::ins_linked_LList(Tx,Tb){node*p

8、,*q;p=newnode;p->d=b;if(head==null){head=p;p

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。