随笔分类 -  无表头链表

里面所有的链表都是无表头的
无表头单链表的总结----从链表中删除某一个年纪的的节点
摘要:1 #include "head.h" 2 struct Student *del_same_age(struct Student*head, int age) 3 { 4 struct Student *p, *pt; int find = 0; 5 p = pt = head; 6 while (p != NULL)//当循环到最后一个节点时 7 ... 阅读全文
posted @ 2016-12-23 22:22 新爱代 阅读(570) 评论(0) 推荐(0)
无表头单链表的总结----从a链表中删去与b链表中有相同ID的那些节点
摘要:1 #include"head.h" 2 struct Student* del_same_ID(struct Student*p1, struct Student*p2) 3 { 4 struct Student *p0 = p1; 5 struct Student *head_a = p1; 6 struct Student *head_b = p2; ... 阅读全文
posted @ 2016-12-23 22:22 新爱代 阅读(304) 评论(0) 推荐(0)
无表头单链表的总结----如何将已经初始化的结构体数组加入链表关系
摘要:1 struct Student 2 { 3 char ID[N_ID]; 4 char name[N_name]; 5 struct Student *next; 6 }alist[LEN_A],blist[LEN_B]; 7 ////以上是结构体 8 //初始化 9 struct Student alist[LEN_A] = { {"101","Wa... 阅读全文
posted @ 2016-12-23 22:21 新爱代 阅读(628) 评论(0) 推荐(0)
无表头单链表的总结----两个链表合并
摘要:#include"head.h" struct Student* insert(struct Student*ahead, struct Student*bhead) { struct Student *pa1, *pa2, *pb1, *pb2; pa1 = pa2 = ahead; pb1 = pb2 = bhead; if ((ahead != NULL)&... 阅读全文
posted @ 2016-12-23 22:20 新爱代 阅读(1235) 评论(0) 推荐(0)
无表头单链表的总结----输出链表
摘要:#include"head.h" void print(struct Student* head) { struct Student *p; printf("There are %d records:\n", sum); p = head; if (p != NULL) { do { printf("... 阅读全文
posted @ 2016-12-23 22:19 新爱代 阅读(292) 评论(0) 推荐(0)
无表头单链表的总结----无限删除和无限插入(在主函数里实现)
摘要:1 #include"head.h" 2 int main() 3 { 4 struct Student *head; 5 struct Student *addinfo; 6 printf("请输入信息(101 wang f s 501)(以“0 0 0 s 0”作为结束标志):\n"); 7 head = input(); 8 prin... 阅读全文
posted @ 2016-12-23 22:18 新爱代 阅读(619) 评论(0) 推荐(0)
无表头单链表的总结----增加节点(原链表为有序的链表)
摘要:1 #include"head.h" 2 struct Student* insert(struct Student*head, struct Student*addinfo) 3 { 4 struct Student *p0, *p1, *p2; //开辟三个结构体指针 5 p2=p1 = head; //头指针赋给p1,p2 6 p0 = addin... 阅读全文
posted @ 2016-12-23 22:15 新爱代 阅读(743) 评论(0) 推荐(0)
无表头单链表的总结----删除节点
摘要:1 #include "head.h" 2 struct Student*del(struct Student*head,char num[N]) 3 { 4 struct Student*p1, *p2; 5 if (head == NULL) //若链表为空,则无需处理 6 { 7 printf("\nl... 阅读全文
posted @ 2016-12-23 22:13 新爱代 阅读(423) 评论(0) 推荐(0)
无表头单链表的总结----动态建立链表
摘要:1 #include "head.h" 2 struct Student *creat() 3 { 4 struct Student *head, *p1, *p2;// 先开辟三个结构体指针,*head,(作为返回的头指针) 5 p1 = p2 =(struct Student *) malloc(LEN); 6 scanf_s("%s %f", p1->n... 阅读全文
posted @ 2016-12-23 22:12 新爱代 阅读(896) 评论(0) 推荐(0)
排序算法----无表头链表插入排序
摘要:/* //对于很小的数源(N<=20),插入排序比快速排序好,此时,插入排序速度快也稳定。 //插入排序只用在小的或是非常接近排好序的输入数据上。 功能:直接插入排序(由小到大) 返回:指向链表表 头的指针 */ /* 直接插入排序的基本思想就是假设链表的前面n-1个节点是已经按键值 (就是用它排序 阅读全文
posted @ 2016-12-23 16:54 新爱代 阅读(542) 评论(0) 推荐(0)