当head作为参数发送给它时,以下代码可以正常工作.由于我是C的新手,我无法理解它是如何工作的.请帮帮我.
struct node *recursiveReverseLL(struct node *list)
{
struct node *revHead;
if (list == NULL || list->link == NULL)
{
return list;
}
revHead = recursiveReverseLL(list->link);
list->link->link = list;
list->link = NULL;
return revHead;
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用这些递归调用提供链接.即)如果链接为,
1 -> 2 -> 3 -> 4
Run Code Online (Sandbox Code Playgroud)
然后hw被改变为,
4 -> 3 -> 2 -> 1
Run Code Online (Sandbox Code Playgroud)