Algorithms/Find maximum/Java findMax method 4

  private int findMin(final int[] i_intaryTab) {
     if ( i_intaryTab.length ==1 ) 
        return i_intaryTab[0];
     int p_intMin = i_intaryTab[0];
     for (int p_intI = 1; p_intI < i_intaryTab.length; p_intI++) 
         if ( p_intMin > i_intaryTab[p_intI] )
            p_intMin = i_intaryTab[p_intI];
     return p_intMin;
  } // end method
  public int  findMax(final int[] i_intaryTab) {
     for ( int p_intI = 0; p_intI < i_intaryTab.length; p_intI++)
         i_intaryTab[p_intI] = i_intaryTab[p_intI] * -1;
     int o_result = findMin(i_intaryTab);
     return o_result * -1;
  } // end method
Last modified on 25 April 2009, at 03:15