struct N{int data;N *next;};
N* reverseLink(N *head)
{
N *p1=head;
N *p2=p1->next;
p1->next=NULL;
while(p2!=NULL){
N *p=p2->next;
p2->next=p1;
p1=p2;
p2=p;
}
head=p1;
return head;
}
链表逆序
最新推荐文章于 2024-08-23 00:00:00 发布
struct N{int data;N *next;};
N* reverseLink(N *head)
{
N *p1=head;
N *p2=p1->next;
p1->next=NULL;
while(p2!=NULL){
N *p=p2->next;
p2->next=p1;
p1=p2;
p2=p;
}
head=p1;
return head;
}