0
I did it using two ties for, but the teacher did not accept.
I need to do the comparison using only a while loop.
EX. vetorA = {1,2,3,4,5,6,7,8}
, vetorB = {3,4,7,8,9,10}
So it works, but it needs to be only with a loop.
public void interseccao(int[] vetorA, int[] vetorB) {
for(int i=0; i < vetorA.length; i++){
for(int j=0; j < vetorB.length; j++){
if(vetorA[i] == vetorB[j]){
int temp = vetorA[i];
System.out.print(temp + " ");
}
Post your code
– Valdeir Psr
It is guaranteed that vectors are always ordered ?
– Isac
Yes, the vectors are ordered.
– SnSilva