帶表頭節點的迴圈雙向鍊錶基本操作

2021-09-11 10:39:13 字數 1307 閱讀 9584

#include #include struct node; 

typedef struct node node;

typedef node * link;

//函式功能:釋放鍊錶

void release(link * head)

p = *head;

*head = null;

free(p);}

//函式功能:建立節點

int node_creat(link * new_node)

}while(!*new_node);

return -1;}

//函式功能:建立帶表頭節點的迴圈雙向鍊錶

void link_creat(link * head)

(*head)->next = *head;

(*head)->prior = *head;}

//函式功能:插入節點,插入方式:頭插

void link_insert_head(link head,link new_node)

//函式功能:插入節點,插入方式:尾插

void link_insert_tail(link head,link new_node)

//函式功能:刪除指定資料的節點

void link_delete(link head,int date)

p = p->next;

}while(p != head);

} //函式功能:釋放鍊錶除表頭節點以外的節點

void link_empty(link head)}

//函式功能:列印鍊錶的資料

void link_display(link head)

if (head->next == head)

link p;

p = head->next;

while ( p != head)

} 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,10);

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 struct node link 功能 設頭結點 返回 void void creat link link head head next head head p...

帶表頭結點的雙向迴圈鍊錶

include include 定義鍊錶資料結構 struct node typedef struct node node typedef struct node link 功能 設頭結點 返回 void void creat link link head head next head head p...

帶表頭節點的鍊錶的基本操作

include include struct node typedef struct node node typedef node link 函式功能 釋放節點 void release link head 函式功能 建立節點並分配空間,連續建立10次不成功就返回 int node creat li...