struct node
{
int id;
char name[32];
node* next;
node* prior;
};
node* head;
int len;
void creat()
{
head=new node;
head->prior=NULL;
head->next=NULL;
node* r=head;
int x;
char name[32];
for(int i=0;i<len;i++)
{
cin>>x;
cin>>name;
node* p=new node;
p->id=x;
strcpy(p->name,name);
r->next=p;
p->prior=r;
r=p;
}
r->next=NULL;
}
void show()
{
node* p=head->next;
while(p)
{
cout<<p->id<<p->name<<endl;
p=p->next;
}
cout<<endl;
}
双链表的尾插法建立输出
最新推荐文章于 2024-04-01 00:25:27 发布