一个循环实现单链表逆置
node *reverse(node *head)
{
node * th=NULL,*P=NULL;
while(head)
{
p = head;
head = head->neaxt;
p->head = th;
th = p;
}
return th;
}
//wz609.blog.51cto.com 有我原图
这里体会是模拟走一次 就如同汉诺塔一样 代码的循环由第一次遍历可以记忆
返回值 可以没有就让head=th原文:http://sts609.blog.51cto.com/11227442/1749367