/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void interseccao(int[] vetorA, int[] vetorB){
int indiceA = 0;
int indiceB = 0;
while (indiceA < vetorA.length && indiceB < vetorB.length){
if (vetorA[indiceA] == vetorB[indiceB]){
System.
out.
print(vetorA
[indiceA
] + " "); indiceA++;
indiceB++;
}
else if (vetorA[indiceA] < vetorB[indiceB]){
indiceA++;
}
else {
indiceB++;
}
}
}
public static void main
(String[] args
){
int[] vetorA = {1,2,3,4,5,6,7,8};
int[] vetorB = {3,4,7,8,9,10};
interseccao(vetorA, vetorB);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCSBwdWJsaWMgc3RhdGljIHZvaWQgaW50ZXJzZWNjYW8oaW50W10gdmV0b3JBLCBpbnRbXSB2ZXRvckIpewogICAgICAgIGludCBpbmRpY2VBID0gMDsKICAgICAgICBpbnQgaW5kaWNlQiA9IDA7CgogICAgICAgIHdoaWxlIChpbmRpY2VBIDwgdmV0b3JBLmxlbmd0aCAmJiBpbmRpY2VCIDwgdmV0b3JCLmxlbmd0aCl7CiAgICAgICAgICAgIGlmICh2ZXRvckFbaW5kaWNlQV0gPT0gdmV0b3JCW2luZGljZUJdKXsKICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQodmV0b3JBW2luZGljZUFdICsgIiAiKTsKICAgICAgICAgICAgICAgIGluZGljZUErKzsKICAgICAgICAgICAgICAgIGluZGljZUIrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmICh2ZXRvckFbaW5kaWNlQV0gPCB2ZXRvckJbaW5kaWNlQl0pewogICAgICAgICAgICAgICAgaW5kaWNlQSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgaW5kaWNlQisrOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKXsKCiAgICAgICAgaW50W10gdmV0b3JBID0gezEsMiwzLDQsNSw2LDcsOH07CiAgICAgICAgaW50W10gdmV0b3JCID0gezMsNCw3LDgsOSwxMH07CgogICAgICAgIGludGVyc2VjY2FvKHZldG9yQSwgdmV0b3JCKTsKICAgIH0KfQ==