数据结构与算法学习:单向链表逆序

1
2
3
4
5
6
7
8
9
10
11
12
ListNode* reverse(ListNode* head){
ListNode *n=head->next;
ListNode *p=NULL;
while(head!=NULL)
{
n=head->next;
head->next=p;
p=head;
head=n;
}
return p;
}
Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

请我喝杯咖啡吧~

支付宝
微信