#include<bits/stdc++.h>
using namespace std;
struct node
{
int data;
struct node *next;
}*head,*tail,*p;
int n;
void built()
{
head=(struct node *)malloc(sizeof(struct node));
tail=head;
while(n--)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
tail->next=p;
tail=p;
}
tail->next=NULL;
}
void print()
{
p=head->next;
while(p)
{
printf("%d",p->data);
if(p->next)
printf(" ");
p=p->next;
}
}
int main()
{
scanf("%d",&n);
built();
print();
}
SDUT2116数据结构实验之链表一:顺序建立链表
最新推荐文章于 2023-07-06 11:31:15 发布