#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
int n,i;
scanf("%d",&n);
struct node *head,*p;
head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
for(i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=head->next;
head->next=p;
}
while(p!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
return 0;
}
2117-数据结构实验之链表二:逆序建立链表 SDUT C语言
最新推荐文章于 2024-08-27 10:56:50 发布