#include<stdio.h>
#include<stdlib.h>
typedef int ElemType;
typedef struct LNode
{
ElemType data;
LNode *next;
}LNode,*LinkList;
void CreateList(LinkList &L,int n)
{
LNode *r,*p;
L = new LNode;
L->next = NULL;
r = L;
for(int i=0;i<n;i++)
{
p = new LNode;
scanf("%d",&p->data);
p->next = NULL;
r->next = p;
r = p;
}
}
void CreateList_1(LinkList &L){
LinkList t;
ElemType data;
printf("");
while (1){
if (scanf("%d",&data) == 1){
t = new LNode;
t->data = data;
t->next = L->next;
L->next = t;
}
if ((getchar()) == '\n') break;
}
}
void Inverse(LinkList &L)
{
LinkList p,q;
p = L->next;
L->next = NULL;
while(p != NULL)
{
q = p->next;
p->next = L->next;
L->next = p;
p = q;
}
}
int main()
{
int n;
LinkList L,L1;
CreateList(L1,n);
printf("逆转后的单链表为:\n" );
Inverse(L);
CreateList_1(L);
return 0;
}