#include <bits/stdc++.h> using namespace std; #define LIST_INIT_SIZE 205 typedef struct { int *data; int length; int listsize; }Sqlist; int index; void InitList_Sq(Sqlist &L) { L.data = (int * )malloc(LIST_INIT_SIZE*sizeof(int)); L.length = 0; L.listsize = LIST_INIT_SIZE; } void ListInsert_Sq(Sqlist &L,int pos,int e) { L.data[pos] = e; L.length++; } void Maopao(Sqlist &L) { int tmp,i,j,len=L.length; for(int i=0;i<len;i++) { for(int j=i+1;j<len;j++) { if(L.data[j]<L.data[i]) { tmp=L.data[j]; L.data[j]=L.data[i]; L.data[i]=tmp; } } } } bool IsHasElem(Sqlist &L,int e) { for (int i=0; i < L.length ; i++) { if (L.data[i] == e) return true; } return false; } Sqlist GetUnion(Sqlist &L1,Sqlist &L2) { Sqlist un; InitList_Sq(un); int ct = 0; for (int i=0; i<L1.length; i++) { if (IsHasElem(L2,L1.data[i])) { ListInsert_Sq(un,ct++,L1.data[i]); } } return un; } int main() { Sqlist Sq1,Sq2,Sq3; InitList_Sq(Sq1); InitList_Sq(Sq2); InitList_Sq(Sq3); int m; scanf("%d",&m); for (int i=0; i<m; i++) { int e; scanf("%d",&e); ListInsert_Sq(Sq1,i,e); } scanf("%d",&m); for (int i=0; i<m; i++) { int e; scanf("%d",&e); ListInsert_Sq(Sq2,i,e); } Maopao(Sq1); Maopao(Sq2); Sq3 = GetUnion(Sq1,Sq2); printf("%d ",Sq3.length); for (int i=0; i<Sq3.length; i++) { if (i < Sq3.length -1) printf("%d ",Sq3.data[i]); else printf("%d ",Sq3.data[i]); } return 0; }