typedef int ElemType;


typedef struct _Node

{

ElemType value;

struct _Node* pnext;

struct _Node* prev;

}node, *pNode;


//创建双向链表

pNode Create_Double_List(int count)

{

pNode pn = NULL;

pNode pb = NULL;


pNode phead = (pNode)malloc(sizeof(node));

printf("请输入第1个结点的值:");

scanf("%d", &phead->value);


if(count == 1)

{

phead->pnext = phead->prev = phead;

return phead;

}

else

{

int i = 0;

// phead->pnext = phead->prev = NULL;

pn = phead;

for(i = 1; i < count; ++i)

{

pb = (pNode)malloc(sizeof(node));

printf("请输入第%d个结点的值:", (i + 1));

scanf("%d", &pb->value);

pn->pnext = pb;

pb->prev = pn;

pn = pb;

}


pn->pnext = phead;

phead->prev = pn;

return phead;

}

}


//正序遍历

void Printf_Next_List_Value(pNode pnode)

{

int i = 0;

pNode pn = pnode;

printf("正序遍历的结果为:");

while(i < g_Count)

{

if(pn->pnext == pn)

{

printf("%3d ", pn->value);

}

if(pn->pnext != pn)

{

printf("%3d ", pn->value);

pn = pn->pnext;

}

i++;

}

printf("\n");

}