From e79d0ca56fdddf81387d75dc43c0a96ff170cbc4 Mon Sep 17 00:00:00 2001 From: mommeja Date: Wed, 10 Sep 2025 16:48:26 +0200 Subject: [PATCH] . --- Résultat.txt | 4 +++- bubblesort.c | 2 +- gmon.out | Bin 3820 -> 3820 bytes student_rank | Bin 21792 -> 21776 bytes student_rank.c | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Résultat.txt b/Résultat.txt index 069614a..5a16c66 100644 --- a/Résultat.txt +++ b/Résultat.txt @@ -50,4 +50,6 @@ index % time self children called name [8] 0.0 0.00 0.00 1 generate_ranks [8] ----------------------------------------------- -Il faut supprimer le bubblesort qui est dans la fonction find_rank_student pour gagner du temps sauf qu'on ne gagne pas assez de temps pour passer en dessous d'une secondes. \ No newline at end of file +On modifie d'abord bubblesort pour qu'il fonctionne correctement en remplaçant swapped ++ par swapped = 1. +Ensuite on supprime le bubblesort qui est dans la fonction find_rank_student pour gagner du temps sauf qu'on ne gagne pas assez de temps pour passer en dessous d'une secondes. +Quand on remplace le bubblesort restant par heapsort, c'est beacoup plus rapide sauf que le tri ne ce fait pas bien. diff --git a/bubblesort.c b/bubblesort.c index 7961fe4..3686a45 100644 --- a/bubblesort.c +++ b/bubblesort.c @@ -14,7 +14,7 @@ void bubblesort(int* array, int length) tmp = array[i-1]; array[i-1] = array[i]; array[i] = tmp; - swapped = 1; + swapped= 1; } } } while(swapped==1); diff --git a/gmon.out b/gmon.out index 002973fc1bc96d569e8908f4341e6ee1ac840bae..c5ffa8759f9bf7e9ae61beabbf2f4b2628c3e601 100644 GIT binary patch delta 165 zcmaDO`$l#{A(tp40|GEIKzNK39eo)YCptPaGH!Hy%QTslPf+&-GXn#ogD6C?t|Wv8 z3od{PI*3379h~?lNANjLKFp_S&nN&@`BNMsdGkIi17iZ3AjeX62F3$uf)RH73;^%9 B7b^e& delta 122 zcmaDO`$l#{A=k!$Da?~u`2?LL85kHC1wC#Y85lVj7#JA17$(aaD%U?{U|?WkVSmNIz`)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$HS z&%{0#L@~0JgD57}GDZdl9v0Tjyb=Z`4pvJ>1_riVkPIVR9RmXcFNn=n0utb0HDP36 zVB%nZ&A`CGC(X#fz>>)m#lXO@h=GBDxe{bA*m5S89Uy@n4D}2Q%piFNHW10d&&a^Q z%ytTSS=-vKdMML@=YZ2+0dz42;(p85kn?Kds1_o<4MhJs(jwcfX17ikAQVL?52crUrrw`#dFrHyxU~qK?*~UC^ zPd($o$^6FV^}84u7`*sF1~W~JU|0qj;S1&CWCzy@iVKnx0DJP15>WHRU=404(*Xd))!0W(2S9B#s7YZEEU zW(EcZ;l)A_AFP2;42*M@!_*5)L)3eKZ4}mr*x|x>aB`oCn)yahq^P;^1E5_b^;0|N^vpD=Q;ngla4FmU_?rB^N? zP!eQ>2ff<|- z&Q0z&7iYi9%)r3Hz%Y5Oxr{W(?P4I)m?lOrf;1~m0TqQ4Ls+dRKQUj;$h~=@MKKen z789uK+0KE?JvW)n-i48OvbVh)S5j$GQch}deo@Kf z#rBGmGwrP>AF=}1V OUKwJ~xP9`=5Oo0ftr)-n diff --git a/student_rank.c b/student_rank.c index c6dc75a..6620a4d 100644 --- a/student_rank.c +++ b/student_rank.c @@ -76,7 +76,7 @@ void sort_students(int** students_rank, int** students_array, int students_numbe { grades[j] = students_array[j][i]; } - bubblesort(grades,students_number); + heapsort(grades,students_number); for(j = 0; j < students_number; j++) { students_rank[j][i] = find_rank_student(students_array[j][i],grades,students_number);