0
I have a matrix for example:
1 4 7
1 3 4 6 7
1 2 3 4 5 6
I have to see the repeating numbers in ALL lines, in the example, the numbers should be the result: 1 and 4. For it is they who repeat in all lines.
Vector<Integer> validos = new Vector<Integer>();
int cont = 0;
for (int linha = 0; linha < resultado.length; linha++)
{
for (int coluna = 0; coluna < resultado.length - 1; coluna++)
{
for (int linha2 = (linha + 1); linha2 < resultado.length; linha2++)
{
for (int coluna2 = 0; coluna2 < resultado.length - 1; coluna2++)
{
if(resultado[linha][coluna] == resultado[linha2][coluna2])
{
cont ++;
}
}
}
}
}
Where the matrix is the variable resultado
, which is a int[][]
, tried to implement a cont
that if there were the number on all rows it would then be worth the number of rows in the matrix, example, 3.
Only the code isn’t working.
The goal is to take these repeated numbers and put in the Vector validos
Three does not appear in the first line. : p
– Randrade
Typing error kk is 1 and 4 in case
– Leonardo
Renan certainty? Where does it? Because it is strange, even using Java8, Eclipse does not show it as deprecated, as some Time methods, etc.
– Leonardo
@lvcs I have no way to post links here, I’m by mobile. But in Google you find much on the subject.
– Renan Gomes