1
2
3
4
5
6
7
8
9
10
11
12
ListNode* reverse(ListNode* head){
ListNode *n=head->next;
ListNode *p=NULL;
while(head!=NULL)
{
n=head->next;
head->next=p;
p=head;
head=n;
}
return p;
}