每日一句 ( 202525 )  

Life doesn't get easier or more forgiving; we get stronger and more resilient.

生活從未變得更加輕松或?qū)捜?,是我們在一點一點變強、變堅韌。———— Steve Maraboli

又是一個單鏈表的實現(xiàn)(頭插法和尾插法)

看了不少資料,之前一直糊涂,感覺剛剛弄明白,所以又寫了一遍單鏈表的實現(xiàn),包括頭插和尾插…C語言的指針果然水深啊。 #include #include //定義鏈表節(jié)點結(jié)構(gòu) struct LinkedList { int data; struct LinkedList *next; }; //定義一個指向struct LinkedList的指針的類型node typedef struct LinkedList *node; /** * 創(chuàng)建一個新節(jié)點 * @return node */ node create_node() { node ...

C語言實現(xiàn)單鏈表的創(chuàng)建、元素添加刪除等操作

最近在學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)和c語言,以下是用c語言寫的一個單鏈表,實現(xiàn)了鏈表的創(chuàng)建和清空,元素的添加和刪除以及鏈表的遍歷,其中元素節(jié)點的添加使用的是尾插法。 以下代碼在c-free/win10下編譯通過 #include // 之前缺少stdlib 感謝Super wan留言指出 #include //定義單鏈表的節(jié)點結(jié)構(gòu) typedef struct node{ int data; struct node *next; } LinkedListNode, *LinkedList; //函數(shù)聲明 LinkedL...