int isLoopList(LinkList L){
LinkList slow,fast;
slow = L;
fast = slow->next;
if (fast==NULL||fast->next==NULL)
return 0;
while (fast!=NULL){
if (fast==slow||fast->next==slow)
return 1;
slow=slow->next;
fast=fast->next->next;
}
}
判断链表是否有环
最新推荐文章于 2023-04-06 17:44:24 发布