#include <stdio.h>
#include <stdlib.h>
//头插法
typedef struct stu{
int x;
struct stu *next;
}s;
void create(s *h,int n)
{
int i;
s *p;
for(i=0;i<n;i++)
{
p=(s*)malloc(sizeof(s));
scanf("%d",&p->x);
p->next=h->next;//第一个p1指针域是空,h指针域记录p1地址给p2指针域;也就是说每个节点的指针域是前一个节点地址;
h->next=p;//h最后储存的是最后输入的一个节点的地址
}
}
void output(s *h)
{
s *r;
r=h->next;
while(r!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
int n;
s *h;
while(scanf("%d",&n)!=EOF)
{
h=(s*)malloc(sizeof(s));
h->next=NULL;
create(h,n);
output(h);
}
return 0;
}