自己试试手的,可以参考看看
#include <stdio.h>
#include<stdlib.h>
typedef struct LIST
{
int data;
struct LIST *next;
}S;
int main()
{
S *head,*p,*q;
int N,a;
head = (LIST*)malloc(sizeof(LIST*));
scanf("%d",&N);
p=(LIST*)malloc(sizeof(LIST*));
scanf("%d",&a);
p->data=a;
head->next=p;
for (int i=2;i<=N;i++)
{
q=(LIST*)malloc(sizeof(LIST*));
scanf("%d",&a);
q->data=a;
p->next=q;
p=q;
}
p->next = NULL;
p = head->next;
while(p!=NULL)
{
printf("%d ",p->data);
p = p->next;
}
return 0;
}