资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
#include#includetypedef struct nodeint data;struct node *next;Node,*LinkList;/创建一个空表LinkList CreateLinkList(LinkList L)L=(LinkList)(new LinkList);/ L=(LinkList )malloc(sizeof(Node);L-next=NULL;return L;/尾插法初始化线性表LinkList InitLinkList(LinkList L,int arr,int length)LinkList p,s;s=L;for(int i=0;idata=arri;s-next=p;s=p;s-next=NULL;return L;/求线性表的长度int Length(LinkList L)LinkList p;p=L-next;int count=0;while(p)count+;p=p-next;return count;/查找void FindData(LinkList L,int location)LinkList p;p=L-next;int j=1;if(locationLength(L)coutnext;j+;if(!p)coutdataLength(p)coutnext;if(!p)coutdata=e;s-next=p-next;p-next=s;/删除void DelateData(LinkList *L,int location)LinkList p,s;p=*L;int j=1;if(locationLength(p)coutnext&jnext;if(!p-next)coutnext;p-next=s-next;/ free(s);void main()LinkList L,m;int data5=2,34,23,1,1;L=CreateLinkList(m);L=InitLinkList(L,data,5);/ FindData(L,6);/ InsertData(DelateData(m=L-next;while(m!=NULL)coutdatanext;
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号