//帶表頭的單向鍊錶
#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_node)
void creat_link (link * head)
void display (link head)
while (p != null)
} void insert_new_node_tail (link head, link new_node)
new_node->next = null;
p->next = new_node; }
void insert_new_node_head (link head, link new_node)
void release (link *head)
}int count (link head)
return n; }
link search (link head,int n)
p = p->next; }
return p; }
link search_before (link head,int n)
q = p;
p = p->next; }
return q; }
void modifier (link p)
void delete1 (link head, int n)
else if ((p->next) == null)
else
} void plus_node (link head, int n)
else
}void inverted_order (link head)
else if (p1->next == null)
else if ((p1->next)->next == null)
else
p2->next = p1;
head->next = p2; }
} void insert_sort(link head, link new_node)
else if (number <= (p->num))
else if (number > (p->num))
else if (number <= ((p->next)->num))
else if (number > ((p->next)->num))
} } }
int main ()
display (head);
printf("有%d個結點.\n",count(head));
printf("輸入結點中成員num的值(查詢名字):");
scanf("%d",&n);
if (search(head,n) == null)
printf("沒有這個數。");
else
printf("%d : %s\n",n, search(head,n)->name);
printf("輸入需要刪除的成員num的值:");
scanf("%d",&n);
delete1 (head,n);
display (head);
printf("輸入乙個值,加入乙個結點:");
scanf("%d",&n);
plus_node(head,n);
display(head);
inverted_order (head);
display (head);
for (i = 0; i < 3; i++)
display(head);
release(&head);
return 0; }
帶表頭鍊錶插入方法
include include include 定義鍊錶節點型別 struct node header void create node hlink new node 分配節點記憶體空間函式 void create link hlink head 建立新的帶表頭鍊錶的函式 帶表頭煉表頭插函式 voi...
帶表頭結點的雙向迴圈鍊錶
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...