struct node *del_list(struct node *head, int num){ struct node *p = head; struct node *pre = NULL; while(p != NULL){ if(p->data == num){ if(pre == NULL){ head = p->next; } else{ pre->next = p->next; } free(p); return head; } pre = p; p = p->next; } printf("node cannot be found"); return head; }

有一个链表其每一个结点的定义为: struct node int data; struct node next; ;现已知该链表的头指针head编写一函数struct node del_liststruct node head int num 删除数据为num的那个节点如果不存在所查找的节点则输出node

原文地址: https://www.cveoy.top/t/topic/g908 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录