我试图跟踪此代码,但在上一次递归调用中得到了不同的结果,而此代码运行良好;怎么样?
//function to reverse linked list implemented stack recursively
void stack_reverse(struct node **head, struct node **head_next)
{
struct node *temp;
if (*head_next != NULL)
{
temp = (*head_next)->next;
(*head_next)->next = (*head);
*head = *head_next;
*head_next = temp;
stack_reverse(head, head_next);
}
}