#include <stdio.h>
#include <stdlib.h>
struct yo {
int data;
struct yo *next;
};
int main() {
struct yo *head,*p,*q,*s;
p=(struct yo*)malloc(sizeof(struct yo));
p->data=10;
head=p;
q=(struct yo*)malloc(sizeof(struct yo));
q->data=20;
p->next=q;
s=(struct yo*)malloc(sizeof(struct yo));
s->data=30;
q->next=s;
s->next=NULL;
struct yo *x;
p->next=q->next; //删头节点 head=p->next ,尾节点 q->next=NULL
x=head;
free(q); //将指针所申请空间释放
while(x!=NULL) {
printf("%d\n",x->data);
x=x->next;
}
return 0;
}
在链表删去头,中间,尾节点
最新推荐文章于 2022-02-25 10:28:29 发布