list_node * relocate(list_node * head)
{
//////在下面完成代码
if(head == nullptr || head->next == nullptr) return head;
list_node* slow = head;
list_node* fast = head;
while(fast->next != nullptr && fast->next->next != nullptr) {
slow = slow->next;
fast = fast->next->next;
}
if(fast->next == nullptr) ;
else if(fast->next->next == nullptr) slow = slow->next;
fast = head;
while(fast->next != slow) fast = fast->next;
fast->next = nullptr;
fast = head;
while(fast != nullptr) {
list_node* tmp = slow;
slow = slow->next;
tmp->next = fast->next;
fast->next = tmp;
fast = tmp->next;
if(fast == nullptr && slow != nullptr)
tmp->next = slow;
}
return head;
}