Here you can find the source of argMin(int[] a)
Parameter | Description |
---|---|
a | a parameter |
public static int argMin(int[] a)
//package com.java2s; /******************************************************************************* * OscaR is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or * (at your option) any later version.//w ww. j a v a2s .c om * * OscaR is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with OscaR. * If not, see http://www.gnu.org/licenses/lgpl-3.0.en.html ******************************************************************************/ public class Main { /** * * @param a * @return the index of a minimum value in a */ public static int argMin(int[] a) { int v = Integer.MAX_VALUE; int ind = -1; for (int i = 0; i < a.length; i++) { if (a[i] < v) { v = a[i]; ind = i; } } return ind; } }