#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
#define M 100
#define N1 200
#define Sqlist struct lists
#define Sqlist1 struct list
#define Sqlists struct list_sus
//定义一个结构体
struct lists{
int date[N];
int length;
};
struct list{
int date1[N];
int length1;
};
struct list_sus{
int dates[N1];
int lengths;
};
//创建的表
Sqlist* sqlist_list()
{
//申请一段空间
Sqlist *L;
L=(Sqlist *)malloc(sizeof(Sqlist));
L->length=-1;
return L;
}
Sqlist1* sqlist_list1()
{
//申请一段空间
Sqlist1 *L;
L=(Sqlist1 *)malloc(sizeof(Sqlist1));
L->length1=-1;
return L;
}
Sqlists* sqlists_lists()
{
//申请一段空间
Sqlists *L;
L=(Sqlists *)malloc(sizeof(Sqlists));
L->lengths=-1;
return L;
}
//插入数据
int sqlist_date(Sqlist *L,int m,int a1[])
{
int i;
if(sqlist_jde(L)==1)
{
printf("data is full\n");
}
for(i=0;i<m;i++)
{
L->length++;
L->date[L->length]=a1[i];
}
return 0;
}
int sqlist_date1(Sqlist1 *L1,int m,int b1[])
{
int i;
if(sqlist_jde1(L1)==1)
{
printf("data is full\n");
}
for(i=0;i<m;i++)
{
L1->length1++;
L1->date1[L1->length1]=b1[i];
}
return 0;
}
//判断是否越界
int sqlist_jde(Sqlist *L)
{
if(L->length>=N-1)
{
return 1;
}
else
{
return 0;
}
}
int sqlist_jde1(Sqlist1 *L1)
{
if(L1->length1>=N-1)
{
return 1;
}
else
{
return 0;
}
}
//数据排序
void sqlist_sort(Sqlist *L)
{
int i,j,temp;
for(i=0;i<=L->length;i++)
{
for(j=0;j<=L->length-i-1;j++)
{
if(L->date[j]>L->date[j+1])
{
temp=L->date[j];
L->date[j]=L->date[j+1];
L->date[j+1]=temp;
}
}
}
}
void sqlist_sort1(Sqlist1 *L1)
{
int i,j,temp;
for(i=0;i<=L1->length1;i++)
{
for(j=0;j<=L1->length1-i-1;j++)
{
if(L1->date1[j]>L1->date1[j+1])
{
temp=L1->date1[j];
L1->date1[j]=L1->date1[j+1];
L1->date1[j+1]=temp;
}
}
}
}
//遍历
int sqlist_show(Sqlist *L)
{
int i;
for(i=0;i<=L->length;i++)
{
printf("%d ",L->date[i]);
}
printf("\n");
return 0;
}
//遍历
int sqlist_show1(Sqlist1 *L1)
{
int i;
for(i=0;i<=L1->length1;i++)
{
printf("%d ",L1->date1[i]);
}
printf("\n");
return 0;
}
int sqlist_shows(Sqlists *L2)
{
int i;
for(i=0;i<L2->lengths;i++)
{
printf("%d ",L2->dates[i]);
}
printf("\n");
printf("%d\n",L2->lengths);
return 0;
}
//按数据大小依次插入;
int Sqlist_sort_sus(Sqlist *L ,Sqlist1 *L1, Sqlists *L2)
{
int i=0,j=0,k=0;
while((i<=L->length)&&(j<=L1->length1))
{
if(L->date[i]<=L1->date1[j])
{
L2->dates[k]=L->date[i];
i++;
k++;
}
else
{
L2->dates[k]=L1->date1[j];
j++;
k++;
}
}
while(i<=L->length)
{
L2->dates[k]=L->date[i];
k++;
i++;
}
while(i<=L->length)
{
L2->dates[k]=L1->date1[i];
k++;
i++;
}
L2->lengths=k;
return 0;
}
int main(int argc,char *argv[])
{
struct lists * L;
struct list *L1;
struct list_sus *L2;
int i,n,n1;
int a[100],b[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&n1);
for(i=0;i<n1;i++)
{
scanf("%d",&b[i]);
}
L=sqlist_list();//获得的地址
sqlist_date(L,n,a);
sqlist_sort(L);
sqlist_show(L);
L1=sqlist_list1();//获得的地址
sqlist_date1(L1,n1,b);
sqlist_sort1(L1);
sqlist_show1(L1);
L2=sqlists_lists();
Sqlist_sort_sus(L,L1,L2);
sqlist_shows(L2);
return 0;
}