/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* ReverseList(ListNode* pHead) { ListNode *p=pHead,*q; if(!p || !(p->next)){//只有一个结点的情况 return p; } q=pHead->next; while(q){ pHead->next=q->next; q->next=p; p=q; q=pHead->next; } return p; } };