“função java que retorna o índice do maior valor em uma matriz” Respostas de código

função java que retorna o índice do maior valor em uma matriz

public int getIndexOfLargest( int[] array )
{
  if ( array == null || array.length == 0 ) return -1; // null or empty

  int largest = 0;
  for ( int i = 1; i < array.length; i++ )
  {
      if ( array[i] > array[largest] ) largest = i;
  }
  return largest; // position of the first largest found
}
Blue And Gold Macaw

função java que retorna o índice do maior valor em uma matriz

int largest = 0;
for ( int i = 1; i < array. length; i++ )
{
if ( array[i] > array[largest] ) largest = i;
}
return largest; // position of the first largest found.
}
Motionless Millipede

Respostas semelhantes a “função java que retorna o índice do maior valor em uma matriz”

Perguntas semelhantes a “função java que retorna o índice do maior valor em uma matriz”

Procure respostas de código populares por idioma

Procurar outros idiomas de código