Pregunta: | 68353 - ORDENAR DIAGONAL EN JAVA |
Autor: | Andres Daza |
Buenas. Necesito ordenar la diagonal principal de una matriz en java. ese es el metodo que hize pero no ordena. gracias por su ayuda. public void burbuja(){ int aux; for(int i=0; i<mat.length-1; i++){ for(int j=0; j<mat.length-1; j++){ if(i==j){ if(mat[i+1][j+1]<mat[i][j]){ aux = mat[i][j]; mat[i+1][j+1] = mat[i][j]; mat[i][j]=aux; } } } } for(int i=0; i<mat.length;i++){ for(int j=0; j<mat.length;j++){ System.out.print(mat[i][j]); } } } |