Node* FindFirstNode(List plist)
{
assert(plist != NULL);
if (plist == NULL)
{
return NULL;
}
Node* p, * q;
p = plist->next->next;//快指针
q = plist->next;//慢指针
assert(p != NULL && q != NULL);
while (p!=NULL&&p->next!=NULL)
{
if (p == q)
{
break;
}
p = p->next->next;
q = q->next;
}
Node* r;
r = plist;
assert(r != NULL);
while (r->next != NULL)
{
if (p == r)
{
break;
}
p = p->next;
r = r->next;
}
return p;
}