链表的删除,我自己做的,不知是否有问题,求教!
struct student *c_port(struct student *head,long num){
struct student *p1,*p2;
p1=head;
p2=head;
do
{if(p1->num=num)&&(p1==head) head=p1->next;\*判断首结点是否符合*\
else
{ p2=p1;
p1=p1->next;
if(p1->num==num)
p2->next=p1->next;
}
}while((p1->next!=NULL)&&(p1->num!=num) \*判断直到尾结点是否符合*\
if(p1->next==NULL) printf("找不到");
}
return(head);
解释:
\* #define NULL 0
struct student
[long num;
struct student *next;
}