#include <stdlib.h>
#include <stdio.h>
typedef struct node
{
int data;
struct node *next;
}node,*list;
void print(node *a)
{
node *p=a;
while(p!=NULL)
{ if(p->next!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
else
{
printf("%d",p->data);
p=p->next;
}
}
}
node* turn(node *a)
{
node *pre,*cur,*next;
pre=NULL;
cur=a;
while(cur)
{
next=cur->next;
cur->next=pre;
pre=cur;
cur=next;
}
return(pre);
}
int main()
{
node *p1,*p2;
node *creat();
p1=creat();
// print(p1);
p2=turn(p1);
print(p2);
return 0;
}
node *creat()
{
int n;
node *s,*r;
list l;
l=(list)malloc(sizeof(node));
//l->data=NULL;
l->next=NULL;
r=l;
scanf("%d",&n);
while(n!=-1)//以-1表示结尾
{
s=(node *)malloc(sizeof(node));
s->data=n;
r->next=s;
r=s;
scanf("%d",&n);
// printf("%d ",r->data);
}
// free(s);
r->next=NULL;
return(l->next);
}