C++练习 | 不使用头插法逆转单链表

void D(PBook pHead)
{
    PBook p,q,s;
    p=pHead->next->next;
    q=p->next;
    s=q->next;
    
    pHead->next->next=NULL;
    p->next=pHead->next;
    
    q->next=p;
    p=q;
    q=s;
    
    while(q->next!=NULL)
    {
        s=q->next;
        q->next=p;
        p=q;
        q=s;
    }
    q->next=p;
    pHead->next=q;
}
原文地址:https://www.cnblogs.com/tsj816523/p/11631171.html