也就是用头插法
#include<stdio.h>
#include<malloc.h>
typedef struct LNode{
int data;
struct LNode*next;
}LNode,*LinkList;
int main(){
LNode*head;
head=(LNode*)malloc(sizeof(LNode));
head->next=NULL;
int n;
scanf("%d",&n);
LNode*p,*r;
int x;
for(int i=0;i<n;i++){
p=(LNode*)malloc(sizeof(LNode));
scanf("%d",&x);
p->data=x;
p->next=head->next;
head->next=p;
}
LNode*a=head->next;
while(a!=NULL){
printf("%d ",a->data);
a=a->next;
}
return 0;
}