编写一个函数,实现单链表逆序,,函数原型如下:
*void reverse_list(single_list head)
程序代码如下:
void reverse_list(single_list *head)
{
single_list *p = head->next; //将链表除头节点的节点保存
head->next = NULL;//将链表断开
single_list *tmp = NULL;
while(p != NULL)
{
tmp = p->next;//将后面还未逆序的节点保存
//将p插入到head的后面
p->next = head->next;
head->next = p;
//将tmp的值赋给p
p = tmp;
}
}
标签:tmp,head,list,next,链表,single,逆序
From: https://www.cnblogs.com/JinBool/p/18162572