#include<stdio.h>
#include<stdlib.h>
#define OK 1
#define ERROR -1
typedef int Status;
typedef int ElemType;
typedef struct LNode{
ElemType data;
struct LNode *next;
}LNode,*LinkList;
Status InitList(LinkList &L){
L = new LNode;
L->next = NULL;
return OK;
}
void CreateList(LinkList &L,int m){
LinkList t;
printf("请输入数值:");
for(int p = 0 ; p < m ; p++){
t = new LNode;
scanf("%d",&t->data);
t->next = L->next;
L->next = t;
}
}
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;
q = L;
p = NULL;
while (q != NULL)
{
p = q;
q = q->next;
p->next = L;
L = p;
}
}
void showList(LinkList L)
{
LinkList p = L;
while (p->next) {
printf("%d ", p->next->data);
p = p->next;
}
printf("\n");
}
int main(){
int n;
LinkList L,L1;
InitList(L1);
CreateList_1(L1);
Inverse(L1);
showList(L1);
return 0;
}