1.当前链表的头就是反转链表后的尾
2.所以遍历一次将链表从后往前插入可得到反转链表和链表头
struct ListNode* ReverseList(struct ListNode* pHead ) {
// write code here
struct ListNode *cur=pHead,*next=NULL,*pre=NULL;
while(cur!=NULL)
{
next = cur->next;//保存下一个链表数据
cur->next=pre;//让这个链表数据指向下一个链表
pre=cur;//指针移动
cur=next;//将cur移动到下一个
}
return pre;
}