头插法
LinkNode* ReverseLinkList(LinkNode* head)
{
if(head == NULL) return NULL;
LinkNode* pre = NULL;
LinkNode* next = NULL;
while(head)
{
next = head->next;
head->next = pre;
pre = head;
head = next;
}
return pre;
}
网友评论