Chaos 鍊錶2 0 簡單單鏈表操作的一站式實現

2021-10-11 17:52:56 字數 1985 閱讀 6543

鍊錶2.0

#include

#include

struct node

;//頭插法

struct node *

head_add

(struct node *p)

t_node->value=n_value;

if(p==

null

) t_node->next=

null

;else t_node->next=p;

return t_node;

}//尾插法

struct node *

tail_add

(struct node *p)

t_node->value=n_value;

t_node->next=

null;if

(p!=

null

) p->next=t_node;

return t_node;

}//定位插入結點

struct node *

insert_node

(struct node *head)

else

t_node->value=n_value;

t_node->next=cur;

if(prev==

null

) head=t_node;

else prev->next=t_node;

return head;}}

//結點刪除

struct node *

delete_node

(struct node *head)

if(prev==

null

) head=cur->next;

else prev->next=cur->next;

free

(cur)

;return head;

}//鍊錶列印

void

print

(struct node *head)

//鍊錶氣泡排序

void

bubble_sort

(struct node *head,

int n)}}

intmain()

printf

("請輸入結點個數:");

scanf

("%d"

,&n)

;printf

("請為每個結點賦值(空格隔開):");

switch

(item)

break;}

printf

("建表完畢.\n");

printf

("第%d次列印鍊錶:"

,time)

;print

(head)

; time++

;while(1

)switch

(item)

printf

("操作完成\n");

printf

("第%d次列印鍊錶:"

,time)

;print

(head)

; time++

;printf

("**********************\n"

"** 請選擇: **\n"

"** 1.繼續操作 **\n"

"** 2.退出 **\n"

"**********************\n"

"請輸入序號:");

scanf

("%d"

,&tuichu)

;while

(tuichu!=

1&&tuichu!=2)

if(tuichu==2)

break;}

return0;

}

簡簡單單的迴圈鍊錶C

資料結構練習 迴圈鍊錶 c 首先,給出一遍鍊錶的 鍊錶 include include using namespace std c語言中不能使用 define bool short define true 1 define false 0 元素為char型別 typedef char elemtyp...

C 簡單單向鍊錶的實現,插入,刪除,列印

直接上 include include using namespace std typedef struct node node 通過模板的使用,可以避免numlist陣列退化成指標 template void makelist node head,t numlist void print node...

C語言實現鍊錶(包含單鏈表和雙向鍊錶各項操作)

筆者通過c語言簡單實現了單鏈表和雙向鍊錶的各類操作 增,刪,查 包含在刪操作的實現內 文章最後有原始碼 改 的操作基於增的操作,較為簡單,就不另外實現了。基本功能如下 1.基本實現了鍊錶的插入 a.尾插法,b.頭插法,c.指定位置插入 2.指定值的節點的刪除 3.指定值的查詢 包含在刪除操作的實現 ...