实验2链表的操作实验内容:1)基础题:编写链表基本操作函数,链表带有头结点(1)CreatList_h()//用头插法建立链表(2)CreateList_t()//用尾插法建立链表(3)InsertList()向链表的指定位置插入元素(4)DeleteList()删除链表中指定元素值(5)FindList()查找链表中的元素(6)OutputList()输出链表中元素2)提高题:(1)将一个头节点指针为heada的单链表A分解成两个单链表A和B,其头结点指针分别为heada和headb,使得A表中含有原单链表A中序号为奇数的元素,B表中含有原链表A中序号为偶数的元素,且保持原来的相对顺序
(2)将一个单链表就地逆置
即原表(a1,a2,
an),逆置后新表(an,an-1,
a1)/*程序功能:单链表基本功能操作编程者:杨天啸日期:2016-04-14版本号:3
0*/#include#includetypedefstructList{intdata;structList*next;}List;voidCreatList_h(List*L)//头插法{inti=0;intn=0;intgoal;List*p;printf("请输入数据的个数:\n");scanf("%d",&n);L->next=NULL;for(i=0;idata=goal;p->next=L->next;//将L指向的地址赋值给p;L->next=p;}}voidCreateList_t(List*L)//尾插法{inti;intn;intgoal;List*p;List*q=L;printf("请输入数据的个数:\n");scanf("%d",&n);for(i=0;idata=goal;q->next=p;q=p;}q->next=NULL;}voidInsList(List*