每日一句 ( 2024920 )  

Years may wrinkle the skin, but to give up enthusiasm wrinkles the soul.

歲月留痕,只及肌膚;激情不再,皺起心靈。———— Samuel Ullman

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

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

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

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