#include<stdio.h>
#include<stddef.h>
#include
using namespace std;
typedef int ElemType;
typedef struct LNode
{
ElemType data;
struct LNode *next;
}LNode,*LinkList;
int InitList(LinkList &L)
{
L=new LNode;
L->next=NULL;
return 1;
}
void DeleteElem(LinkList &L,int i)
{
LNode *r,*q;
r=L;
for(int j=0;j<i-1;j++)
{
r=r->next;
}
q=r->next;
r->next=q->next;
delete q;
}
void CreatList_T(LinkList &L,int n)
{
L=new LNode;
L->next=NULL;
for(int j=0;j<n;j++)
{
LNode *p=new LNode;
cin>>p->data;
p->next=L->next;
L->next=p;
}
}
void CreatList_H(LinkList &L,int n)
{
L=new LNode;
L->next=NULL;
LNode *r;
r=L;
for(int j=0;j<n;j++)
{
LNode *p=new LNode;
cin>>p->data;
p->next=NULL;
r->next=p;
r=p;
}
r->next = NULL; // 确保最后一个节点的 next 指向 NULL
}
void print(LinkList L)
{
LNode *p=L->next;
while(p!=NULL)
{
printf("%d\n",p->data);
p=p->next;
}
}
int main()
{
LinkList L=NULL,*p;
InitList(L);
//CreatList_T(L,5);
CreatList_H(L,5);
//ListInsert(L,1,4);
//DeleteElem(L,3);
print(L);
return 0;
}