Node* findMid(Node* head)
{
Node *p=head,*q=head;
if (head==0||head->next==0)
return head;
do
{
p=p->next;
q=q->next->next;
} while (q&&q->next);
return p;
}
查找链表的中间节点
最新推荐文章于 2025-01-11 17:24:50 发布
Node* findMid(Node* head)
{
Node *p=head,*q=head;
if (head==0||head->next==0)
return head;
do
{
p=p->next;
q=q->next->next;
} while (q&&q->next);
return p;
}