ListNode* find_midlist(ListNode* head)
{
ListNode *p1, *p2;
if (head == NULL || head->next == NULL)
{
return head;
}
p1 = p2 = head;
while (1)
{
if (p2->next != NULL && p2->next->next != NULL)
{
p2 = p2->next->next;
p1 = p1->next;
}
else
{
break;
}
}
return p1;
}
阅读(431) | 评论(0) | 转发(0) |