标签:
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* reverseList(struct ListNode* head) { if(head == NULL) return NULL; struct ListNode *p = head; struct ListNode *q = p->next; struct ListNode *r = NULL; while(q!=NULL) { r = q->next; q->next = p; p =q; q = r; } head->next = NULL; head = p; }
标签:
原文地址:http://www.cnblogs.com/neyer/p/4504600.html