#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
单向循环链表(C++实现)
最新推荐文章于 2022-08-31 15:44:14 发布