#include<stdio.h>
#include "stdlib.h"
#define NULL 0
typedef struct LNode
{
int data;
struct LNode *next;
}LNode;typedef struct LNode LinkList;
Create_List(void)
{
LinkList *L;
int data;
LinkList *p,*q;
L=(LinkList *)malloc(sizeof(LNode));
L->next=NULL;
q=L;
scanf("%d",&data);
while(data!=0)
{
p=(LinkList *)malloc(sizeof(LNode));
p->data=data;
p->next=q->next;
q->next=p;
q=p;
scanf("%d",&data);
}return L;
}
void TranverseList(LinkList *L)
{
LinkList *p;
p=L->next;
if (p==NULL)
{
printf("nil/n");
return;
}
while(p!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
printf("/n");
}
DeleteList (LinkList *L,int m)
{
LinkList *s;
LinkList *p;
p=L;
s=L->next;
while(s->data!=m)
{
p=s;
s=s->next;
}p->next=s->next;
free(s);
return L;
}
InsertList (LinkList *L,int n)
{
LinkList *q,*p;
q=L->next;
while(q->data!=n)
{
q=q->next;
p=(LinkList *)malloc(sizeof(LNode));
p->data=n;
p->next=q->next;
q->next=p;
q=p;
}return L;
}
int main()
{
LinkList *L;int n,m;
L=Create_List();
TranverseList(L);
scanf("%d",&m);
DeleteList (L ,m);
TranverseList(L);
scanf("%d",&n);
InsertList(L,n);
TranverseList(L);
getch();
return 0;
}