50 lines
794 B
C
50 lines
794 B
C
#include <stdio.h>
|
|
|
|
int test_if_have_value(int a[20],int c[40], int n, int n_, int value){
|
|
int temp=1;
|
|
for (int i = 0; i < n; i++) {
|
|
if (a[i] == value){
|
|
temp=0;
|
|
}
|
|
}
|
|
if(temp){
|
|
c[n_]=value;
|
|
n_++;
|
|
}
|
|
return n_;
|
|
}
|
|
int main()
|
|
{
|
|
int a[20],b[20],c[40],n_=0,n1,n2,temp;
|
|
scanf("%d",&n1);
|
|
for(int i=0;i<n1;i++){
|
|
scanf("%d",&a[i]);
|
|
}
|
|
scanf("%d",&n2);
|
|
for(int i=0;i<n2;i++){
|
|
scanf("%d",&b[i]);
|
|
}
|
|
|
|
for(int i=0;i<n1;i++){
|
|
n_=test_if_have_value(b,c,n2,n_,a[i]);
|
|
}
|
|
for(int i=0;i<n2;i++){
|
|
n_=test_if_have_value(a,c,n1,n_,b[i]);
|
|
}
|
|
|
|
for(int i=0;i<n_;i++){
|
|
for(int j=i+1;j<n_;j++){
|
|
if(c[i]>c[j]){
|
|
temp=c[i];
|
|
c[i]=c[j];
|
|
c[j]=temp;
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i=0;i<n_;i++){
|
|
printf("%d ",c[i]);
|
|
}
|
|
return 0;
|
|
}
|