How to traverse a vector with the quantity of the second vector?

2
int[] teste1 = {3524, 79, 2573, -4216, -4126, -4169, 1876, 2903, 2702, 1090, -6544, -8600};

int[] teste2 = {3524, 79, 2573, -4216, -4126, -4169};

I have a vector with 12 records and another with 6, I need to go twice without repeating.

Example, first process from 3524 to 4169 then 1876 to -8600 .

I'm doing this to compare the second with the first one.

    
asked by anonymous 18.05.2015 / 21:45

1 answer

2

Do this:

int[] teste1 = {3524, 79, 2573, -4216, -4126, -4169, 1876, 2903, 2702, 1090, -6544, -8600};

    int[] teste2 = {3524, 79, 2573, -4216, -4126, -4169};

    for(int t1=0; t1<teste1.length; t1++){
        int t2 = t1%6;    
        System.out.println("Comparando teste1:"+ teste1[t1] + "com teste2:"+teste2[t2]);

    }

The mod of the two vectors will return exactly what you want! Follow the exit:

Comparando teste1:3524 com teste2:3524
Comparando teste1:79 com teste2:79
Comparando teste1:2573 com teste2:2573
Comparando teste1:-4216 com teste2:-4216
Comparando teste1:-4126 com teste2:-4126
Comparando teste1:-4169 com teste2:-4169
Comparando teste1:1876 com teste2:3524
Comparando teste1:2903 com teste2:79
Comparando teste1:2702 com teste2:2573
Comparando teste1:1090 com teste2:-4216
Comparando teste1:-6544 com teste2:-4126
Comparando teste1:-8600 com teste2:-4169
    
18.05.2015 / 22:16