#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
int i,n;
struct node *head,*p,*tail;
head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
scanf("%d",&n);
for(i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=NULL;
tail->next=p;
tail=p;
}
p=head;
while(p->next!=NULL)
{
printf("%d ",p->next->data);
p=p->next;
}
return 0;
}
/***************************************************
User name: TJRAC6015203228魏杰
Result: Accepted
Take time: 0ms
Take Memory: 104KB
Submit time: 2016-11-01 13:29:25
****************************************************/
sdut2116数据结构实验之链表一:顺序建立链表
最新推荐文章于 2020-05-18 13:00:32 发布