while (head!=NULL)
{
p=head;
head=head->next;
p->next=newhead;
newhead=p;
}
head=newhead;
谁可以详细帮我解释下这段代码啊
尤其是最后一句。。有点蒙。。
谢谢!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
单链表的原地 逆置.
p, newhead初始值都是null.
最后newhead指向 原链表的最后一个元素, 也就是新链表的头结点.
你看看这个:
http://blog.csdn.net/feliciafay/article/details/6841115