#include<bits/stdc++.h>
using namespace std;
struct node{
int data;
node *pre,*next;
};
int main(){
node *head,r;//定义头结点和尾结点
head=new node;//动态申请内存空间
head->pre=NULL;//指针域初始化为空
head->next=NULL;//指针域初始化为空
r=head;//此时的头结点也是尾结点
/ 输入 */
node p;
int x;
while(cin>>x){
p=new node;
p->data=x;
p->pre=r;
p->next=NULL;
r->next=p;
r=p;
}
/ 输出 /
p=head->next;
while(p->next!=NULL){
cout<<p->next->data<<" ";
p=p->next;
}
cout<<p->data;
/ 删除单链表中的p结点 /
p->pre->next=p->next;
p->next->pre=p->pre;
/ 在p结点之后插入一个结点s /
s->next=p->next;
s->pre=p;
p->next->pre=s;
p->next=s;
/ 双向循环链表 */
r->next=head;
head->pre=r;
return 0;
}