// 实现利用栈将链表逆置的算法
Linklist * backlist(Linklist *head)
{
Linklist *P = head->next;
Initstack(s);
while(P != NULL)
{
push(s,P->data); // 将链表中的数据全部入栈
P = P->next;
}
P = head->next;
while(!empty(s))
{
P->data = pop(s); // 将出栈后的数据再次入栈
P = P->next;
}
}
链表的逆置(利用栈)
![](https://img-home.csdnimg.cn/images/20240711042549.png)