typedef struct node
{ int data;
struct node *next;
}NODE;
int x,i;
NODE *creat()
{ NODE *head,*p,*s;
int x;
head=(NODE*)malloc(sizeof(NODE));
p=head;
printf("输入整数,以0标志结束\n");
scanf("%d",&x);
while(x!=0)
{ s=(NODE*)malloc(sizeof(NODE));
s->data=x;
p->next=s;
s->next=NULL;
p=s;
scanf("%d",&x);
}
p->next=NULL;
p=head;
head=head->next;
free(p);
return head;
}
void delete(head,x)
{ NODE *head,*p,*q;
if(head==NULL) printf("链表下益\n");
if(head->data==x)
{ p=head;
head=head->next;
free(p);
}
else
{ q=head; p=head->next;
while(p!=NULL&&p->data!=x)
if(p->data!=x)
{ q=p;p=p->next;
}
if(p!=NULL)
{ q->next=p->next;
free(p);
}
else printf("没找到\n");
}
}
main()
{ NODE *head,*p;
head=creat();
while(p!=NULL)
{ printf("%d",p->data);
p=p->next;
}
printf("输入要删除的节点:");
scanf("%d",&x);
delete(head,x);
p=head;
while(p!=NULL)
{ printf("%d",p->data);
p=p->next;
}
} //谁能调通这个程序啊?