#include<iostream>
#include<stdlib.h>
using namespace std;
typedef struct Lnode
{
int data;
struct Lnode* next;
}Linknode;
int main()
{
int n;
while(cin>>n)
{
Linknode *head,*p;
head=(Linknode*)malloc(sizeof(Linknode));
head->next=NULL;
for(int i=0;i<n;i++)
{
int data;
cin>>data;
p=(Linknode*)malloc(sizeof(Linknode));
p->data=data;
p->next=head->next;
head->next=p;
}
while(p)
{
cout<<p->data<<" "<<endl;
p=p->next;
}
}
return 0;
}
数据结构-单线性链式-头插法
最新推荐文章于 2022-06-19 22:02:55 发布