TD4_DEV51_Lawson/student_rank.C

20 lines
835 B
C

#include <stdlib.h>
void sort_students(int** students_rank, int** students_array, int students_number, int grades_number)
{
int i = 0, j = 0;
for(i = 0; i < grades_number; i++) // boucle sur les matières
{
int * grades = (int*) malloc(students_number*sizeof(int)); // allocation de mémoire
for(j = 0; j < students_number; j++) // boucle sur les étudiants
{
grades[j] = students_array[j][i]; // copie des notes
}
bubblesort(grades,students_number); // tri des notes
for(j = 0; j < students_number; j++) // attribution du rang
{
students_rank[j][i] = find_rank_student(students_array[j][i],grades,students_number); // recherche du rang
}
free(grades); // libération de la mémoire allouée
}
}