三、链表管理结构体123456struct List{ struct Node *head; struct Node *tail; int len;}; 1、初始化链表123456789101112131415161718// 初始化链表struct List * init_list(void){ struct List *list = malloc(sizeof(struct List)); if(list == NULL) { return NULL; } // 分配头节点空间 list->head = malloc(sizeof(struct Node)); if(list->head == NULL) return NULL; list->tail = list->head; list->len = 0; return list;} 2、尾插1234567// 尾插void insert_tail(struct Node *new, struct List * list){ list->tail->next = new; list->tail = new; list->len++;} 3、遍历123456789101112// 遍历void display_list(struct List * list){ struct Node *tmp = list->head->next; for(int i=0; i<list->len; i++) { printf("%d->", tmp->data); tmp = tmp->next; } printf("\n");}