# 双向链表的建立

struct stu
{
int num;
struct stu *next;
};


#include <iostream>
#include <stdlib.h>
using namespace std;
struct stu
{
int num;
struct stu *next;
};
void show(struct stu *q)
{
while(q->next!=NULL)
{
cout<<q->next->num<<" ";
q=q->next;
}
cout<<endl;
}
int main()
{
struct stu *p,*q;
int n;
while(cin>>n)
{
p=(struct stu *)malloc(sizeof(struct stu));
q=p;
p->num=-999999;
for(int i=0;i<n;i++)
{
p->next=(struct stu *)malloc(sizeof(struct stu));
p=p->next;
cin>>p->num;
}
p->next=NULL;
show(q);
}
}


struct stu
{
struct stu *last;
int num;
struct stu *next;
};


#include <iostream>
#include <stdlib.h>
using namespace std;
struct stu
{
struct stu *last;
int num;
struct stu *next;
};
void show1(struct stu *q)
{
while(q->next!=NULL)
{
cout<<q->next->num<<" ";
q=q->next;
}
cout<<endl;
}
void show2(struct stu *k)
{
while(k->last!=NULL)
{
cout<<k->num<<" ";
k=k->last;
}
cout<<endl;
}
int main()
{
int n;
struct stu *p,*q,*t,*k;
while(cin>>n)
{
p=(struct stu *)malloc(sizeof(struct stu));
q=p;
p->last=NULL;
p->num=-99999;
for(int i=0;i<n;i++)
{
t=p;
p->next=(struct stu *)malloc(sizeof(struct stu));
p=p->next;
p->last=t;
cin>>p->num;
}
p->next=NULL;
k=p;
show1(q);
show2(k);
}
return 0;
}


input：

6
5 6 2 3 1 2

output:

5 6 2 3 1 2
2 1 3 2 6 5

0