#include<stdio.h>
#include<stdlib.h>
#define ERROR 0
#define OK 1
typedef int ElemType;
typedef int Status;
typedef struct LNode
{
ElemType data;
struct LNode *next;
}LNode,*LinkList;
Status InitList_L(LinkList &L)
{
L=(LinkList)malloc(sizeof(LNode));
if(!L)
return ERROR;
L->next=L;
}
Status ClearList_L(LinkList &L)
{
struct LNode *p,*q;
if(L->next==L)
return OK;
p=L->next;
while(p!=L)
{
q=p->next;
free(p);
p=q;
}
L->next=L;
}
Status DestroyList_L(LinkList &L)
{
struct LNode *p,*q;
if(L==NULL)
return OK;
p=L->next;
while(p!=L)
{
q=p->next;
free(p);
p=q;
}
L->next=L;
free(L);
L=0;
return OK;
}
Status CreatList_LT(LinkList &L,int n)
{
L=(LinkList)malloc(sizeof(sizeof(LNode)));
L-&
单向循环链表(C++实现)
最新推荐文章于 2022-08-31 15:44:14 发布
本文详细介绍了如何使用C++编程语言实现单向循环链表,包括链表节点的定义、插入、删除、遍历等操作,旨在帮助读者深入理解数据结构中的链表概念。
摘要由CSDN通过智能技术生成