单链表的逆置

题目

编写程序实现对单链表的逆置。

逆置函数

void invert(SingleList *L){
    Node *p = L->first, *q;
    L->first = NULL;
    while(p){
        q = p->link;
        p->link = L->first;  //p->link = NULL
        //为下一次逆置做准备
        L->first = p;
        p = q;
    }
}

版权声明:本文为博主原创文章,如有错误,恳请大家在评论区指出,在下不胜感激~如要转载注明出处即可~
本文首发于个人博客:Wonz の Blog

猜你喜欢

转载自blog.csdn.net/Wonz5130/article/details/82292121
今日推荐