#include <stdio.h>
#include <stdlib.h>
struct node
{
int date;
struct node *next;
}*head=NULL,*q=NULL,*t=NULL,*bl=NULL,*p=NULL;
//head头 q尾 t中间 bl中间
int main()
{
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
p=(struct node *)malloc(sizeof(struct node));
if(head==NULL)
{
head=p;
}
else
{
t->next=p;
p->next=NULL;
}
scanf("%d",&p->date);
t=p;
}
p=head;
while(p!=NULL)
{
printf("%d",p->date);
if(p->next!=NULL)
{
printf(" ");
}
else
{
printf("\n");
}
p=p->next;
}
return 0;
}
顺序建立链表
最新推荐文章于 2022-02-24 10:36:26 发布