#include<stdio.h> typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; void InvertLinkedList(LinkList &L) { LinkList p=L; L=NULL; while(p!=NULL) { LinkList s=p; p=p->next; s->next=L; L=s; } } int main() { int n,i; LinkList L=NULL ; scanf("%d",&n); for(i=1;i<=n;i++) { LinkList s=new LNode; s->data=i; s->next=L; L=s; } LinkList L1=L; while(L1) { printf("%d ",L1->data) ; L1 = L1->next ; } printf(" "); InvertLinkedList(L); while(L) { printf("%d ",L->data) ; L=L->next ; } printf(" "); return 0 ; }