Array Metodo de Ordenamiento Burbuja


Metodo de Ordenacion Burbuja 


 package vectores;
import java.util.Collections;
/**
*
* @author Reynaldo
*/
public class Vectores {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

int n[] = {5,9,2,7,6,4,3,1,45,67,10,23};

int tmp,i,j, LI, LS;

LI = 0;
LS = 11;

for(i = LI; i <= LS - 1; i++){
for(j = LI; j <= LS - 1; j++){
if(n[j] > n[j + 1]){
tmp = n[j];
n[j] = n[j + 1];
n[j + 1] = tmp;
}
}
}

for(i = 0 ; i < n.length ; i ++){
System.out.println("Elemento de la Posicion "+"["+ i +"]" + " = " + n[i]);

}
System.out.println();
for(i = 0 ; i < n.length ; i ++)
System.out.print(" " + n[i]);


System.out.println();
System.out.println();
}
}

Comentarios