typedef
struct node
link;
void
create
(link *head)
p=head->next;
i =0;
while
(p!=
null)}
/* 拿乙個指標指向拍好序的鍊錶,乙個指向老鍊錶的指標,乙個是在新鍊錶裡面移動指標
*/void
sort
(link *head)
u = p->next;
p->next = r->next;
r->next=p;
p=u;}}
link *
merge
(link *a,link*b)
p=p->next;
}else
} pc->next=p?p:q;
free
(b);
return c;
}// 該題的思路是換了一下頭 原來為head-->node1--->node2--->node3
//turn to tail<---node1<---node2<---node3,直接返回了尾部即可
link *
reverselist
(link *a)
//進行鍊錶的反轉,當前結點的 next 指標指向前乙個結點,實現鍊錶方向的反轉,此時發生了斷鏈
pnow->next = pre;
//勿忘斷鏈的情形,需要使用 pre 指標儲存狀態,pre 等價於是後移乙個結點
pre = pnow;
pnow = pnext;
//pnow 後移乙個結點
if(pre&&pnow&&pnext)
printf
("pnow->num:%d,pre->num:%d,pnext->num:%d\n"
,pnow->num,pre->num,pnext->num)
;printf
("\n");
}return tail;
}int
process_linklist()
printf
("\n");
printf
("create b\n");
create
(b);
sort
(b);
pb=b->next;
printf
("sort b is;\n");
while
(pb)
printf
("\n");
printf
("begin to merge c\n");
c=merge
(a,b)
; pc=c->next;
//pc is head nodelist
printf
("merge is:");
while
(pc)
printf
("\n");
printf
("begin to reverse:\n");
c =reverselist
(c);
printf
("reverse linklist is;\n");
while
(c)printf
("\n");
return0;
}int
main()
鍊錶的處理
在graph coloring中,使用雙向鍊錶 開始在windows vc平台上除錯,正常後,移植到ubuntu下,用g 編譯,發現總是拋段錯誤,在當前目錄下產生core檔案 段錯誤,核心已轉儲 若未產生,ulimit c unlimit gdb main core 定位到雙鏈表操作 min pri...
鍊錶的簡單處理
include include define len sizeof struct student struct student int n 動態建立鍊錶 struct student creat void else p2 next p1 p2 p1 p1 struct student malloc ...
7 3煉表處理
目錄 1.malloc函式 2.靜態鍊錶 鍊錶的結點一般包括兩部分組成,分別是資料域和指標域 struct node該函式在stdlib.h標頭檔案下用於申請動態記憶體的函式,其返回型別是申請的同變數型別的指標。typename p typename malloc sizeof typename i...