轩辕

运筹帷幄世界在我手中!

导航

单链表删除节点

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);

}

posted on 2013-02-23 11:56  峻华  阅读(77)  评论(0)    收藏  举报