#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
typedef int ElemType;
typedef struct DNode {
ElemType data;
struct DNode *prior, *next;//前驱节点和后驱节点
}DNode, *DLinklist;
//初始化为空的循环双链表
bool InitLinkList(DLinklist &L) {
L = (DNode *)malloc(sizeof(DNode));//分配一个头结点
if (L == NULL)//分配失败
return false;
L->prior = NULL;//头结点的prior为空
L->next = NULL;//头结点的next指向头结点
return true;
}
//判断循环链表是否为空
bool Empty(DLinklist L) {
if (L->next == L)
return true;
else
return false;
}
//插入
bool InsertLNode(DNode *p, DNode *s) {
s->next = p->next;//将节点s插入到节点p之后
p->next->prior = s;
s->prior = p;
p->next = s;
}
04-05
1480
06-01
900