它的结构如下图:
List.c
#include"List.h"
//得到一个结点
LTNode* GetNode(DataType x)
{
LTNode* newnode = (LTNode*)malloc(sizeof(LTNode));
if (newnode == NULL)
{
perror("GetNode : malloc");
return NULL;
}
newnode->data = x;
newnode->next = NULL;
newnode->prior = NULL;
return newnode;
}
//初始化
LTNode* ListInit()
{
LTNode* phead = GetNode(-1);
phead->next = phead;
phead->prior = phead;
return phead;
}
//打印函数
void ListPrint(LTNode* phead)
{
LTNode* cur = phead->next;
while (cur!=phead)
{
printf("%d ", cur->data);
cur = cur->next;
}
printf("\n");
}
//尾插
void ListPushBack(LTNode* phead, DataType x)
{
assert(phead);
//LTNode* newnode = GetNode(x);
//LTNode*