#include <stdio.h>
#include <stdlib.h>
typedef struct stu{
int data;
struct stu *next;
}s,*link;
void output(link h)//输出
{
s *p;
p=h->next;
while(p!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
printf("\n");
}
link lianhe(link h1,link h2)//将两个链表联合
{
s *q;
q=h1;
while(q->next!=NULL)
{
q=q->next;
}
q->next=h2->next;
return h1;
}
void paixu(link h)
{
s *p,*q;
int t;
for(p=h->next;p!=NULL;p=p->next)
{
for(q=p->next;q!=NULL;q=q->next)
{
if(p->data<q->data)
{
t=p->data;
p->data=q->data;
q->data=t;
}
}
}
}
int main()
{
link h1,h2,h3;
int x,flag=0;
s *r1,*p1,*r2,*p2;
h1=(s*)malloc(sizeof(s));
h2=(s*)malloc(sizeof(s));
h3=(s*)malloc(sizeof(s));
h1->next=NULL;h2->next=NULL;h3->next=NULL;
r1=h1;r2=h2;
while(scanf("%d",&x)!=EOF)
{
if(x==0)
{
if(flag==0)
{
r1->next=NULL;
flag++;
}
else
{
r2->next=NULL;
break;
}
}
else
{
if(flag==0)
{
p1=(s*)malloc(sizeof(s));
p1->data=x;
r1->next=p1;
r1=p1;
}
else
{
p2=(s*)malloc(sizeof(s));
p2->data=x;
r2->next=p2;
r2=p2;
}
}
}
h3=lianhe(h1,h2);
paixu(h3);
output(h3);
return 0;
}