链表逆置…

C语言 码拜 9年前 (2015-11-12) 857次浏览
void reverse(struct student *ls)
{
    struct student *last = ls->next;
    struct student *pre = ls;
    struct student *cur = ls->next;
    struct student *next = NULL;
    while(cur)
    {
        next = cur->next;
        cur->next = pre;
        pre = cur;
        cur = next;
    }
    ls->next = pre;
    last->next = NULL;
}

这是将链表逆置的函数,头节点不变,
while里面的循环本人实在是看不懂。
哪位高手能通俗点讲一下么?谢谢!

解决方案:20分
参看:http://blog.csdn.net/zhangxiangdavaid/article/details/26291113
假如,看不懂,可以边看边画图~
解决方案:20分

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明链表逆置…
喜欢 (0)
[1034331897@qq.com]
分享 (0)