代码如下:
bool is_circle_list(LinkNode *pHead)
{
LinkNode *pOne = pHead, *pTwo = pHead;
while(1)
{
pOne = pOne->next;
pTwo = pTwo->next->next;
if(pOne == pTwo)
return true;
if(pTwo==NULL || pTwo->next==NULL)
return false;
}
}
bool is_circle_list(LinkNode *pHead)
{
LinkNode *pOne = pHead, *pTwo = pHead;
while(1)
{
pOne = pOne->next;
pTwo = pTwo->next->next;
if(pOne == pTwo)
return true;
if(pTwo==NULL || pTwo->next==NULL)
return false;
}
}