單鏈表的基本操作 單鏈表的建立 插入 刪除結點等

2022-09-11 06:09:12 字數 840 閱讀 4449

(1)單鏈表的建立

(2)建立結點

(3)列印結點

(4)鍊錶的插入【頭插法】

(5)鍊錶的刪除【指定位置刪除】

適合新手初步認識學習單鏈表的基本操作

#include #include 

#include

//結構體----結點由資料域+指標域構成

struct

node ;

//建立鍊錶(表頭)

struct node*createlist()

//建立結點

struct node* createnode(int

data) //

列印結點(遍歷結點)

void printlist(struct node*headnode )

printf("\n

");}//

鍊錶的插入:插入結點---插入那個鍊錶、插入結點的資料是多少

void insertnodebyhead(struct node* headnode,int

data)

//鍊錶的刪除:指定的位置刪除 ---刪除那個鍊錶、刪除的資料是多少

單鏈表的基本操作 單鏈表的建立 插入 刪除結點等

1 單鏈表的建立 2 建立結點 3 列印結點 4 鍊錶的插入 頭插法 5 鍊錶的刪除 指定位置刪除 include include include 結構體 結點由資料域 指標域構成 struct node 建立鍊錶 表頭 struct node createlist 建立結點 struct node...

單鏈表的建立及基本操作

鍊錶作為資料結構中最容易理解的結構,我們需要對它的基本操作非常熟悉 結點結構 typedef struct node node,snode 基本操作 初始化 初始化 snode init 建立鍊錶 頭插法建立單鏈表 snode create1 int n return head 尾插法建立單鏈表 s...

單鏈表的基本操作

include include typedef struct lnodelnode,linklist 定義單鏈表 void create linklist linklist l 逆序實現 linklist q l for int i 1 i 5 i 正序實現 初始化單鏈表 void printf l...