我有以下短代码,它是解决链表反转问题的解决方案。
void backwardslist(atom** head) {
atom* first;
atom* second;
if (*head == NULL) return; //if list is empty
first = *head;
second = first->next; // intuitive
if (second == NULL) return;
backwardslist(&second); // recursive call with 2nd one as head, after we got variables
first and second
first->next->next = first; // when we get to the end, we rearrange it
first->next = NULL; // so last one is pointing to first, first is pointing to NULL
*head = second; // I dont understand this part, so the head is changing from the last,
to the second element as the recursion goes to the beginning or am i
missing something?
}
不是第二个=(指向递归中两个指针中的第二个的指针)吗?
所以第一次,我明白,它应该指向最后一个,
但是随着递归的建立,它不断地改变*头到秒。
正在使用的第二个自动取款机中有什么?
感谢你们