解体思路:原先指向后边节点的指针,现将它改成指向前一个节点。
---------------------------------------------------------
struct linka {
int data;linka* next;
};
void reverse(linka*& head)
{
if(head ==NULL)
return;
linka*pre, *cur, *ne;
pre=head;
cur=head->next;
while(cur)
{
ne = cur->next;
cur->next = pre;
pre = cur;
cur = ne; }
head->next = NULL;
head = pre;
}
---------------------------------------------------------------------------