链表的反转

1 void reverse(ListNode*& pre,ListNode* cur,ListNode* nxt){
2         while(cur){
3             nxt=cur->next;
4             cur->next=pre;
5             pre=cur;
6             cur=nxt;
7         }
8     }

定义一个这样的函数:   初始: pre指向nullptr ;  最后pre 返回链表的头指针。 

原文地址:https://www.cnblogs.com/yy-1046741080/p/12434521.html