#include<stdio.h>
#include<stdlib.h>
typedef struct LNode
{
int data;
struct LNode *next;
}LNode,*Linklist;
Linklist creatlist(Linklist L,int a[],int n)
{
LNode *s,*r;
L=(LNode *)malloc(sizeof(LNode));
L->data=a[0];
r=L;
if(n==1)
L->next=NULL;
for(int i=1;i<n;i++)
{
s=(LNode *)malloc(sizeof(LNode));
s->data=a[i];
r->next=s;
r=r->next;
}
return L;
}
void deleteLNode(Linklist L,int x)
{
LNode *p;
if(L==NULL)
return;
if(L->data==x)
{
p=L;
L=L->next;
free(p);
deleteLNode(L->next,x);
}
else
deleteLNode(L->next,x);
}
int main()
{
Linklist L=NULL;
int a[]={1,2,2,4};
int n=4;
Linklist creatlist(L,a,4);
deleteLNode(L,2);
while(L)
{
printf("%d ",L->data);
L=L->next;
}
return 0;
}