#include<stdio.h>
#include<malloc.h>
typedef struct node
{
int data;//数据域
struct node* next;//指针域
}LNode, * LinkList;
LinkList linklistA() {
LinkList A = (LinkList)malloc(sizeof(LNode));//头结点
A->data = -1;
A->next = NULL;
LNode* s,*r=A;
int x;
printf("请输入A表内容\n");
scanf("%d",&x);
while (x != -1) {
s = (LinkList)malloc(sizeof(LNode));
s->data = x;
r->next=s;
r=s;
printf("请输入A表内容\n");
scanf("%d",&x);
}
r->next=NULL;
return A;
}
void Reverse(LinkList H){
LNode *p,*q;
p=H->next;
H->next=NULL;
while(p){
q=p;
p=p->next;
q->next=H->next;
H->next=q;
}
}
int main() {
LNode* A;
LinkList r=NULL;
A = NULL;
A = linklistA();
Reverse(A);
A=A->next;
while (A) {
printf("%d ", A->data);
A = A->next;
}
return 0;
}