一、题意
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* reverseList(struct ListNode* head){ } //返回3
二、思考过程
struct ListNode* reverseList(struct ListNode* head){ struct ListNode *tmp; struct ListNode *pre=NULL; while(head){ tmp=head->next; head->next=pre; pre=head; head=tmp; } return pre; }