单链表实验.pdf

上传人:H****o 文档编号:56648454 上传时间:2022-11-02 格式:PDF 页数:7 大小:33.76KB
返回 下载 相关 举报
单链表实验.pdf_第1页
第1页 / 共7页
单链表实验.pdf_第2页
第2页 / 共7页
点击查看更多>>
资源描述

《单链表实验.pdf》由会员分享,可在线阅读,更多相关《单链表实验.pdf(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、实验二单链表实验一、实验目的1、掌握用 Visual C+6.0上机调试单链表的基本方法2、掌握单链表的插入、删除、查找、求表长以及有序单链表的合并算法的实现二、实现内容1、单链表基本操作的实现 问题描述 要在带头结点的单链表h中第 i 个数据元素之前插入一个数据元素x,首先需要在单链表中寻找到第 i-1 个结点并用指针p指示,然后申请一个由指针s 指示的结点空间,并置 x为其数据域值,最后修改第i-1 个结点,并使 x结点的指针指向第i 个结点,要在带头结点的单链表h中删除第 i 个结点,首先要计数寻找到第i 个结点并使指针p指向其前驱第 i-1 个结点,然后删除第i 个结点并释放被删除结点

2、空间。基本要求 用链式存储结构实现存储 实现提示 链式存储结构不是随机存储结构,即不能直接取到单链表中某个结点,而要从单链表的头结点开始一个一个地计数寻找。2、求表长以及有序单链表的合并算法的实现 问题描述 假设有两个按元素值递增次序排列的线性表,均以单链表形式存储。请编写算法将这两个单链表归并为一个按元素值递减次序排列的单链表,并计算表长。要求利用原来两个单链表的结点存放归并后的单链表。基本要求 用链式存储结构实现存储实验代码#include#include#define null 0/-定义节点-typedef struct List int data;struct List*next;L

3、ist;/-构造链表-List*InitList(int n)int i;List*head,*p,*q;head=(List*)malloc(sizeof(List);/构造头结点 if(!head)exit(0);/判断是否成功分配内存 q=head;head-data=0;/记录链表长度 head-next=null;for(i=0;inext=head-next;head-next=p;*/-/-尾插-p-next=q-next;q-next=p;q=p;head-data+;/长度自增 printf(输入数据第%d 个数据:n,head-data);scanf(%d,&(p-data

4、);return head;/-插入-void Insert(List*head,int position,int elem)int i;List*p,*q;if(positionhead-data+1)printf(插入位置非法!);exit(0);p=head;for(i=1;inext;q=(List*)malloc(sizeof(List);q-data=elem;q-next=p-next;p-next=q;head-data+;printf(成功将%d 插入到第%d 个位置!n,elem,position);/-删除-void Delete(List*head,int positi

5、on)int i;List*p,*q;if(!head)printf(链表为空!);exit(0);p=head;q=p-next;文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2

6、Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5

7、I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2

8、Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5

9、I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2

10、Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5

11、I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4 if(positionhead-data)printf(非法位置!);exit(0);for(i=1;inext;q=p-next;p-next=q-next;printf(成功删除第%d 个位置上的元素:%dn,positi

12、on,q-data);free(q);head-data-;/-排序(由小到大)-void sort(List*head)int temp;List*p,*q;for(p=head-next;(p-next)&(head-data1);p=p-next)for(q=p-next;q;q=q-next)if(q-datadata)temp=p-data;p-data=q-data;q-data=temp;/-有序合并-void Unite_List(List*head,List*nhead)int n=0;List*p,*q,*pre;sort(head);sort(nhead);pre=hea

13、d;p=pre-next;q=nhead-next;while(q)文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1

14、V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

15、M8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1

16、V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

17、M8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1

18、V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

19、M8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4 if(!p)pre-next=q;head-data+=nhead-data;break;else if(q-datadata)/nhead表中当前元素小于head当前元素,插入其前面 nhead-next=q-next;/nhead链表头指针跳过 q后移nhead-data-;q-nex

20、t=p;/接入后继 pre-next=q;/接入前驱head-data+;pre=q;p=pre-next;q=nhead-next;else pre=p;p=pre-next;free(nhead);/-查找位置-void Search_Position(List*head,int elem)int i,position;List*p;p=head;if(!head)printf(链表为空!);exit(0);for(i=1;idata;i+)p=p-next;if(elem=p-data)position=i;printf(发现元素%d 在表中的位置:%dn,elem,position);

21、exit(0);文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6

22、L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8

23、H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6

24、L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8

25、H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6

26、L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8

27、H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4 printf(在表中未发现元素%dn,elem);/-查找元素-void Search_Element(List*head,int position)int i;List*p;p=head;if(!head)printf(链表为空!);exit(0);if(positionhead-data)printf(非法位置!);exit(0);fo

28、r(i=1;inext;printf(第%d 个位置的元素为:%dn,position,p-data);/return p-data;/-遍历-void ShowMessage(List*head)List*p;int i;p=head;if(!head)/判空 printf(链表为空!);exit(0);for(i=0;idata;i+)if(i%5=0)printf(n);p=p-next;printf(%d,p-data);文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编

29、码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J

30、5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编

31、码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J

32、5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编

33、码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J

34、5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编

35、码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4 printf(n);/-求表长度-int GetLength(List*head)int length;if(!head)printf(链表为空!);exit(0);length=head-data;return length;/-销毁链表-void Destroy(List*head)int i;List*p;/if(!head)printf(链表不存在!);exit(0);/p=head-next;for(i=0;idata;i+)free(head);head=p;p=p-next;free(head);prin

36、tf(成功销毁链表!n);/-主函数-void main()int length;/记录长度 List*head1,*head2;head1=InitList(7);/构造长度为 7的链表 head2=InitList(9);文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V

37、6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM

38、8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V

39、6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM

40、8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V

41、6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM

42、8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4 ShowMessage(head1);/遍历链表 length=GetLength(head1);/获取长度printf(表长为:%

43、dn,length);Insert(head1,4,11);/插入一个元素ShowMessage(head1);/遍历链表length=GetLength(head1);/获取新长度printf(表长为:%dn,length);Search_Element(head1,3);/按位置查找元素Delete(head1,2);/删除元素length=GetLength(head1);/获取新长度printf(表长为:%dn,length);ShowMessage(head1);Search_Position(head1,6);/查找元素位置sort(head1);/对链表 head1排序print

44、f(排序后!n);ShowMessage(head1);/输出排序后的数据 Unite_List(head1,head2);/合并printf(合并后!n);length=GetLength(head1);/获取长度printf(表长为:%dn,length);ShowMessage(head1);/显示合并后的数据Search_Position(head1,6);/查找合并后的位置Destroy(head1);/销毁链表 文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

45、M8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1

46、V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

47、M8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1

48、V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

49、M8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1

50、V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:CM8W7O6L5I9 HQ7J9J5W1V6 ZQ8H2Q4M6A4文档编码:C

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁