链表逆置
node *reverse(node *head)
{
node *p1, *p2, *p3;
p1=head, p2=p1->next;
if(head==null || head->next==null)
return head;
while(p2)
{
p3=p2->next;
p2->next=p1;
p1=p2;
p2=p3;
}
head->next=null;
head=p1;
return head;
}
链表逆置
node *reverse(node *head)
{
node *p1, *p2, *p3;
p1=head, p2=p1->next;
if(head==null || head->next==null)
return head;
while(p2)
{
p3=p2->next;
p2->next=p1;
p1=p2;
p2=p3;
}
head->next=null;
head=p1;
return head;
}