/*
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* p = pHead;
ListNode* q;
ListNode* list = NULL;
while(p != NULL){
q = p->next;;
p->next = list;
list = p;
p = q;
}
return list;
}
};



京公网安备 11010502036488号