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

Posted tsj816523

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;

 

以上是关于C++练习 | 不使用头插法逆转单链表的主要内容,如果未能解决你的问题,请参考以下文章