#include<stdio.h>
#include <malloc.h>
typedef struct LNode{
int data;
struct LNode *next;
}LNode, *LinkList;
void creatL(LinkList &L,int n){
LNode *r;
r = NULL;
L = NULL;
for(int i =1;i<=n;i++){
LNode *p = (LinkList)malloc(sizeof(LNode));
p->next = NULL;
printf("请输入第%d个元素:",i);
scanf("%d",&p->data);
if(r == NULL){
L = p;
r = p;
}
else{
r->next = p;
r = p;
}
}
}
int main(){
LNode *L;
int n;
printf("请输入元素个数:");
scanf("%d",&n);
creatL(L,n);
LNode *read;
read = L;
while(read){
printf("%d ",read->data);
read = read->next;
}
return 0;
}