#include<iostream>
using namespace std;
class Node
{
public:
int data;
Node *pnext;
Node *pre;
};
class List
{
public:
Node *phead,*ptail;
Node *pnewhead;
public:
List()
{
Node *ptemp;
phead=ptail=NULL;
int tempdata;
cin>>tempdata;
while(tempdata)
{
ptemp=new Node;
ptemp->data=tempdata;
if(!phead)
{
phead=ptail=ptemp;
phead->pre=ptail;
ptail->pnext=phead;
}
else
{
ptail->pnext=ptemp;
ptemp->pre=ptail;
ptail=ptemp;
}
cin>>tempdata;
}
ptail->pnext=phead;
phead->pre=ptail;
}
void point()
{
Node *ptemp;
ptemp=phead;
if(ptemp==NULL)
{
cout<<"空链表"<<endl;
}
else
{
while(ptemp!=ptail)
{
cout<<ptemp->data<<" ";
ptemp=ptemp->pnext;
}
cout<<ptemp->data<<" ";
cout<<endl;
}
}
};
int main()
{
cout<<"输入0结束"<<endl;
List Lt;
Lt.point();
system("pause");
return 0;
}
using namespace std;
class Node
{
public:
int data;
Node *pnext;
Node *pre;
};
class List
{
public:
Node *phead,*ptail;
Node *pnewhead;
public:
List()
{
Node *ptemp;
phead=ptail=NULL;
int tempdata;
cin>>tempdata;
while(tempdata)
{
ptemp=new Node;
ptemp->data=tempdata;
if(!phead)
{
phead=ptail=ptemp;
phead->pre=ptail;
ptail->pnext=phead;
}
else
{
ptail->pnext=ptemp;
ptemp->pre=ptail;
ptail=ptemp;
}
cin>>tempdata;
}
ptail->pnext=phead;
phead->pre=ptail;
}
void point()
{
Node *ptemp;
ptemp=phead;
if(ptemp==NULL)
{
cout<<"空链表"<<endl;
}
else
{
while(ptemp!=ptail)
{
cout<<ptemp->data<<" ";
ptemp=ptemp->pnext;
}
cout<<ptemp->data<<" ";
cout<<endl;
}
}
};
int main()
{
cout<<"输入0结束"<<endl;
List Lt;
Lt.point();
system("pause");
return 0;
}