Saturday, June 18, 2005

Busca la posicion del menor numero

/*
* Created on 06/18/2005
*
* Busca la posicion del menor numero
*/
package estructura;

/**
* @author vns
*
*/
public class MenorPos {

/**
*
*/
public MenorPos() {
super();
}

public static void main(String[] args) {
}

public static int menor( int[] num ){
int menor = num[0];
int pos = 0;

for (int i = 0; i < num.length; i++) {
if (num[i] < menor) {
menor = num[i];
pos = i;
}
}

return pos;
}
}

0 Comments:

Post a Comment

<< Home