单链表删除节点
node *del(node *head,int num)
{
node *p1,*p2;
p1=head;
while(num!=p1->data&&p1->next!=NULL)
{
p2=p1; p1=p1->next;
}
if(num==p1->data)
{
if(p1==head)
{
head=p1->next;
free(p1);
else
p2->next=p1->next;
}
else
printf("\n%d could not been found".num);
return (head);
}
浙公网安备 33010602011771号