/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* reverseList(struct ListNode* head) {
struct ListNode *pre=NULL;
struct ListNode *next=NULL;
if(head==NULL ) return NULL;
while(head!= NULL)
{
next=head->next; //保存下一节点
head->next=pre; //断开,指向前一节点
pre=head; //往前移
head=next; //往前移
}
return pre;
}