#include<stdio.h>
#include"malloc.h"
#include<stdlib.h>
#define listinitsize 100
#define OVERFLOW -1
typedef struct sqlist{
int*elem;
int length;
int listsize;
}sqlist;
sqlist la,lb,lc;
void printlist();
sqlist initlist(){
sqlist l;
l.elem=(int*)malloc(listinitsize*sizeof(int));
if(!l.elem)exit(OVERFLOW);
l.length=0;
l.listsize=listinitsize;
return l;
}
sqlist creatlist(sqlist l,int num){
int j,p;
for(j=1;j<=num;j++){
scanf("%d",&p);
l.elem[j]=p;
l.length++;
}
printlist(l);
return l;
}
sqlist addlist(sqlist la,sqlist lb,sqlist lc){
int i=0,j=0,k=0;
while(i<=la.length&&j<=lb.length){
if(la.elem[i]<=lb.elem[j]){
lc.elem[k]=la.elem[i];
i++;k++;}
else{
lc.elem[k]=lb.elem[j];
k++;
i++;
}
}
while(i<=la.length){
lc.elem[k]=la.elem[i];
k++;i++;
}
while(j<=lb.length){
lc.elem[k]=lb.elem[j];
k++;j++;}
lc.length=k+1;
return lc;
}
void printlist(sqlist l){
int i;
for(i=1;i<=l.length;i++){
printf("%d",l.elem[i]);
printf("\n");
}
}
sqlist delsame(sqlist l){
int i,j,k;
if(l.length>0){
j=0;
for(i=1;i<l.length;i++){
k=0;
while(k<=j&&l.elem[k]!=l.elem[i])
k++;
if(k==j+1)
l.elem[j++]=l.elem[i];
}
}
l.length=j;
return l;
}
sqlist change(sqlist l){
int i,t;
for(i=1;i<=l.length/2;i++){
t=l.elem[i];
l.elem[i]=l.elem[l.length-i];
l.elem[l.length-i]=t;
}
return l;
}
void main()
{
int num,num1;
clrscr();
la=initlist();
lb=initlist();
lc=initlist();
printf("please input the numbers of you want about la:");
scanf("%d",&num);
printf("\n");
la=creatlist(la,num);
printf("please input the numbers of you want about lb:");
scanf("%d",&num1);
printf("\n");
lb=creatlist(lb,num1);
printf("the list of la:\n");
printlist(la);
printf("the list of lb:\n");
printlist(lb);
lc1=addlist(la,lb,lc);
delsame(lc);
change(lc);
printf("the list of lc:\n");
printlist(lc1);
}