首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

双链表安插自动排序

2013-07-04 
双链表插入自动排序今天开了一上午无聊的会议,利用一些时间想了一下,双列表插入自动排序问题。这双链表还是

双链表插入自动排序

今天开了一上午无聊的会议,利用一些时间想了一下,双列表插入自动排序问题。这双链表还是花了我很多时间,早上测试结果,总是不对是因为我的list_node输出造成的,让我误以为打印结果不对。  1 /* doublylinkedlist.c */                                                                                    2 #include <stdlib.h>        3 #include <stdio.h>  4 #include "doublylinkedlist.h"  5     6 struct node tailsentinel;  7 struct node headsentinel = {0, NULL, &tailsentinel};  8 struct node tailsentinel = {0, NULL, &headsentinel};  9    10 static link head = &headsentinel; 11 static link tail = &tailsentinel; 12  56 void insert_sort(link p) 57 { 58     link node = head; 59     for(;node->next != tail && node->next->item < p->item; node=node->next); 60     p->next = node->next; 61     p->pre = node; 62     node->next->pre=p; 63     node->next = p; 64 }

?空列表情况:
双链表安插自动排序
?

非空是 插入情况:


双链表安插自动排序
?

热点排行