School-Coding-Cpp/sfusi/selectionsort matrice.cpp

16 lines
514 B
C++

void selectionSortMatrice(int matrice[][6], int righe, int colonne) {
for (int j = 0; j < colonne; j++) {
for (int i = 0; i < righe - 1; i++) {
int minIdx = i;
for (int k = i + 1; k < righe; k++) {
if (matrice[k][j] < matrice[minIdx][j]) {
minIdx = k;
}
}
int temp = matrice[i][j];
matrice[i][j] = matrice[minIdx][j];
matrice[minIdx][j] = temp;
}
}
}