循环链表
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; }

浙公网安备 33010602011771号