#include <iostream>
#include <cstdio>
using namespace std;
typedef int Elem;
typedef int Status;
typedef struct DulList
{
/* data */
Elem data;
struct DulList *prior;
struct DulList *next;
} DulList, *DulLinkList;
Status InitDulList(DulLinkList &L)
{
L = new DulList;
L->next = NULL;
L->prior = NULL;
return 1;
}
Status CreatDulList_H(DulLinkList &L, int num)
{
L = new DulList;
L->next = NULL;
for (int i = 1; i <= num; i++)
{
DulList *p = new DulList;
cin >> p->data;
p->next = L->next;
if (L->next)
L->next->prior = p;
L->next = p;
p->prior = L;
}
return 1;
}
Status ShowDulList(DulLinkList &L)
{
DulList *q = L->next;
while (q->next)
q = q->next;
q->next = L->next;//怎么双向没写 我试了一下 把尾巴指向头 就循环了...
DulList *p = L->next;
while (p)
{
cout << p->data << " ";
p = p->next;
}
return 1;
}
int main()
{
DulLinkList L;
//1
InitDulList(L);
//1
CreatDulList_H(L, 3);
//1
ShowDulList(L);
}