其他分享
首页 > 其他分享> > 5-1 单链表逆转

5-1 单链表逆转

作者:互联网

下列代码的功能是返回带头结点的单链表L的逆转链表。

List Reverse( List L )
{
    Position Old_head, New_head, Temp;
    New_head = NULL;
    Old_head = L->Next;

    while ( Old_head )  {
        Temp = Old_head->Next;
        Old_head->Next=New_head;  \\
        New_head = Old_head;  
        Old_head = Temp; 
    }
    L->Next=New_head;\\
    return L;
}

标签:head,单链,Old,Temp,List,Next,New,逆转
来源: https://www.cnblogs.com/link-way/p/16698303.html