循环链表

typedef struct LNode{
    int data;
    struct LNode *next;
}LNode,*LinkList;

//初始化一个循环单链表
bool InitLidt(LinkList &L){
    L=(LNode*)malloc(sizeof(LNode));  //分配一个头结点
    if(L==NULL)
     return false;
     L->next=L;  //头结点next指向头结点 
     return true; 
} 

 

typedef struct DNode{
    int data;
    struct DNode *next,*prior;
}DNode,*DLinkList;

//初始化一个循环双链表
bool InitDLinkList(DLinkList &L){
    L=(LNode*)malloc(sizeof(LNode));  //分配一个头结点
    if(L==NULL)
     return false;
     L->prior=L;
     L-next=L;
     return true; 
} 

 

posted @ 2020-04-18 01:19  iiiiiki  阅读(120)  评论(0)    收藏  举报