【发布时间】:2018-02-18 10:21:46
【问题描述】:
我正在尝试使用递归来反转链表。当我在反转后显示列表时,我只得到原始列表的第一个元素 `
void reve(node *a,node *b,node *c,node *h1)
{
if(c->next==NULL)
{
c->next=b;
b->next=a;
return ;
}
reve(a->next,b->next,c->next,h1);
c->next=b;
b->next=a;
if(a==h1)
{
a->next=NULL;
}
return ;
}`
【问题讨论】:
-
你调试了吗?
标签: c++ c++11 recursion data-structures linked-list