题解 | #数值的整数次方#
反转链表
http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
牛子
/*
struct ListNode {
int val;
struct ListNode next;
ListNode(int x) :
val(x), next(NULL) {
}
};/
class Solution {
public:
ListNode* ReverseList(ListNode* pHead) {
ListNode *p=pHead;
if(p==NULL)
return NULL;
else
{
ListNode *pre=pHead;
ListNode *tmp=pHead;
p=p->next;
pHead->next=NULL;
while(p!=NULL)
{
tmp=p->next;
p->next=pre;
pre=p;
p=tmp;
}
return pre;
}
}
};