📄 llist.cpp
字号:
#include "LList.h"
#include <iostream>
using namespace std;
bool LList:: append(int elem){
tail=tail->next=new Node(elem);
return true;
}
void LList::print(){
Node *temp;
temp = fence;
do
{
cout << temp->e <<" ";
temp = temp ->next;
}while (temp!=fence);
}
////////////判断是否循环/////////
bool LList::circleInList()
{
if(head == NULL || head->next == NULL)
{
return false;
}
if(head->next == head)
{
fence = head;
return true;
}
Node *pTemp1 = head; //step 1
Node *pTemp = head->next; //step 2
while(pTemp != pTemp1 && pTemp != NULL && pTemp->next != NULL)
{
pTemp1 = pTemp1->next;
pTemp = pTemp->next->next;
}
if(pTemp == pTemp1)
{
fence = pTemp;
return true;
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -