# include<stdio.h>
# include<stdlib.h>
typedef struct node
{
int data ;
struct node* next;
}linklist;
bool IsLoop( linklist* pll)
{
bool flag = false;
linklist* fast = pll;
linklist* slow = pll;
if( fast == NULL )
{
flag = false;
}
while( fast && fast->next )
{
fast = fast->next-next;
slow = slow->next;
if( fast == slow )
{
flag = true;
}
}
return flag;
}
练习:判断单链表是否为环--C实现
最新推荐文章于 2020-03-24 20:46:23 发布