#include #include struct node;
typedef struct node node;
typedef node * link;
//函式功能:釋放節點
void release(link * head)}
//函式功能:建立節點並分配空間,連續建立10次不成功就返回
int node_creat(link * new_node)
}while(!*new_node);
return -1;}
//函式功能:建立帶有頭結點的鍊錶
void link_creat(link * head)
(*head)->next = null;}
//函式功能:插入節點,插入方式:頭插
void link_insert_head(link head,link new_node)
//函式功能:插入節點,插入方式:尾插
void link_insert_tail(link head,link new_node)
new_node->next = p->next;
p->next = new_node;}
//函式功能:刪除指定資料的節點
void link_delete(link head,int date)
p = p->next;
}} //函式功能:刪除所有節點
void link_empty(link head)}
//列印煉表裡的資料
void link_display(link head)
if (head->next == null)
link p;
p = head->next;
while ( p != null)
} int main()
new_node->num = i + 1;
//link_insert_head(head,new_node);
link_insert_tail(head,new_node);
}link_display(head);
link_delete(head,1);
link_display(head);
link_empty(head);
link_display(head);
release(&head);
link_display(head);
return 0;
}
帶表頭節點的迴圈雙向鍊錶基本操作
include include struct node typedef struct node node typedef node link 函式功能 釋放鍊錶 void release link head p head head null free p 函式功能 建立節點 int node cre...
帶表頭的單向鍊錶
帶表頭的單向鍊錶 include include struct node typedef struct node node typedef struct node link void all malloc ok link new node link creat new node link new n...
帶表頭結點的雙向迴圈鍊錶
include include 定義鍊錶資料結構 struct node typedef struct node node typedef struct node link 功能 設頭結點 返回 void void creat link link head head next head head p...