#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));
head->next=NULL;
while(n--)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=head->next;
head->next=p;
}
}
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();
}
SDUT2117数据结构实验之链表二:逆序建立链表
最新推荐文章于 2024-05-22 11:07:35 发布