网址:https://leetcode.com/problems/reverse-linked-list/
直接参考92:https://www.cnblogs.com/tornado549/p/10639756.html
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* reverseList(ListNode* head)
{
if(!head)
return NULL;
ListNode* a = NULL;
ListNode* b = head;
ListNode* c = b->next;
while(c)
{
b->next = a;
a = b;
b = c;
c = c->next;
}
b->next = a;
return b;
}
};