题目描述:
输入: 1->2->3->4->5->NULL
输出: 5->4->3->2->1->NULL
struct ListNode {
* int val;
* struct ListNode *next;
* };
struct ListNode* reverseList(struct ListNode* head){
struct ListNode * result = NULL;//逆置的第一个节点
struct ListNode * c = head;
while (c != NULL){
struct ListNode * n = c->next;
c->next = result;
result = c;
c = n;
}
return result;
}