#inlcued<stdio.h>
#define N 5 //原始的链表元素个数
int main(){
struct List{
int data;
struct List *next;
};
struct List *head,*node;
for(int i=0;i<N;i++){
node=(struct List*)malloc(sizeof(struct List));
node->next=head->next;
head->next =node;
node->data=i;
} //创建链表
node=(struct List*)malloc(sizeof(struct List));
node->next=head->next;
head->next =node;
node->data=100;
int num=N+1;//在表头插入新的数
struct List *p;
for(p=head->next ;*p!=NULL;p=p->next){
if(p->data==3){ //假定K(data=3)
struct List *pp;
for(pp=p->next,*nest;*pp!=NULL;pp=nest){
nest=pp->next;
free(pp);
}
p->next=NULL;//删除k(data=3)后的链表
}
}
for(p=head->next ;*p!=NULL;p=p->next){
if(p->data==3){ //假定K=3
node=(struct List*)malloc(sizeof(struct List));
node->next=p->next;
p->next =node;//在data=3的数据后插入新数
node->data=10;
num=N+1;
}
}
p=head->next;
for(p;p!=NULL;p=next){
next=p->next;
free(p);
}//释放链表
return 0;
}