# 有序集合的交运算

#include <stdio.h>
typedef struct Vector{
int size, length;
int *data;
}Vector;

Vector init(Vector *vector, int size) {
vector->size = size;
vector->length = 0;
vector->data = (int *)malloc(sizeof(int) * size);
}

void intersect(Vector *A, Vector *B) {
int count = 0;
int k = 0;
Vector *C = (Vector *)malloc(sizeof(Vector));

for(int i = 0,j = 0; i < A->size; ) {

if(A->data[i] == B->data[j]) {
count++;
C->data[k++] = A->data[i];
i++;
j++;
}

if(A->data[i] < B->data[j]) {
i++;
}

if(A->data[i] > B->data[j]) {
j++;
}

}

printf("%d\n",count);
for(int i = 0; i < count; i++) {
if(i != 0) {
printf(" ");
}
printf("%d",C->data[i]);
}

}

void main(){
int m,a;
Vector *A = (Vector *)malloc(sizeof(Vector));
Vector *B = (Vector *)malloc(sizeof(Vector));
scanf("%d",&m);
init(A,m);
for(int i = 0; i < m; i++) {
scanf("%d ",&A->data[i]);
// printf("%d ",A->data[i]);
}

scanf("%d",&m);
init(B,m);
for(int i = 0; i < m; i++) {
scanf("%d ",&B->data[i]);
// printf("%d ",B->data[i]);
}

intersect(A,B);
return 0;
}

01-15 2976