编码实现链表逆序

时间:2015-04-03 11:22:47   收藏:0   阅读:151
Node Reverse(Node head){
    if(head == NULL)
        return head;
    Node 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;
    return head;
}

原文:http://blog.csdn.net/sxhlovehmm/article/details/44851427

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!