标签:nod code ext val null offer 反转 span 剑指offer
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* ReverseList(ListNode* pHead) { if(pHead==NULL) { return NULL; } ListNode* cur=NULL; ListNode* pre=NULL; ListNode* nex=NULL; cur=pHead; nex=cur->next; while(1) { if(nex==NULL) { break; } pre=cur; cur=nex; nex=nex->next; nex->next=cur; } return cur; } };
标签:nod code ext val null offer 反转 span 剑指offer
原文地址:http://www.cnblogs.com/159269lzm/p/7295204.html