1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
int[][] matrice={{1,2,3,4,5,6,7,8,9,0},{11,12,13,14,15,16,17,18,19,10}};
for (int i = 0; i < matrice[0].length; i++) {
for (int j = i+1; j < matrice[0].length; j++) {
if(matrice[0][i]>matrice[0][j]){
int var=matrice[0][i];
matrice[0][i]=matrice[0][j];
matrice[0][j]=var;
var=matrice[1][i];
matrice[1][i]=matrice[1][j];
matrice[1][j]=var;
}
}
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < matrice[i].length; j++) {
System.out.println(matrice[i][j]+" ");
}
System.out.println("");
} |
Partager