Compare commits

2 Commits
main ... main

Author SHA1 Message Date
4e34aa3aa6 hahah 2025-09-15 14:27:14 +02:00
2412cd021a Multijoueur 2025-09-10 17:27:29 +02:00
6 changed files with 79 additions and 4 deletions

View File

@@ -1,9 +1,31 @@
// Bubblesort Algorithm
// M.Menault 2024
void bubblesort(int* array, int length)
{
void bubblesort(int* array, int length){
int swapped, i, tmp;
do
{
swapped = 0;
for(i=1;i<length;i++)
{
if(array[i-1] > array[i])
{
tmp = array[i-1];
array[i-1] = array[i];
array[i] = tmp;
swapped=1;
}
}
} while(swapped==1);
}
int swapped, i, tmp;
do
{
swapped = 0;
@@ -19,3 +41,40 @@ void bubblesort(int* array, int length)
}
} while(swapped==1);
}
int * test = (int*) malloc(length*sizeof(int));
int max = -1;
for (j=1;j<length;j++){
int indice = 0;
for(i=1;i<length;i++){
if(array[i]>max){
indice = i ;
max =array[i];
}
}
test[indice]=max;
array[indice]=-1;
}
for (j=1;j<length;j++){
do
{
swapped = 0;
for(i=1;i<length;i++)
{
if(array[i-1] > array[i])
{
tmp = array[i-1];
array[i-1] = array[i];
array[i] = tmp;
swapped++;
}
}
} while(swapped==1)
}

13
compte_rendue.md Normal file
View File

@@ -0,0 +1,13 @@
on s'est rendu compte que bubblesort et find_rank_student font enormement d'appel et qu'il prenne tous autant de temps
on va donc regarder leurs codes et voir ce qui peut etre optimiser
ps : le code est pas commenter j'aime pas (Maxime Lebreton)
pps : Ouais j'suis d'accord avec mon camarade ci-dessus, la prochaine fois faite des faux commentaires pour nous rendre encore plus confus. (Marvin Aubert)
il y avait 2 appel de bubblesort j'ai retirer le mauvais donc le temps n'étais pas gagné après la suppression du bon le code est bien plus rapide
Maxime LEBRETON
Marvin AUBERT

BIN
gmon.out Normal file

Binary file not shown.

4
short.c Normal file
View File

@@ -0,0 +1,4 @@
#include <stdio.h>
#include <stdlib.h>

BIN
student_rank Executable file

Binary file not shown.

View File

@@ -55,7 +55,6 @@ int find_rank_student(int student_grade, int* grades_array, int students_number)
{
int position = -1;
int i = 0;
bubblesort(grades_array,students_number);
for(i = students_number-1; i >= 0; i--)
{
if(grades_array[i] == student_grade)
@@ -77,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);
bubblesort(grades,students_number);
for(j = 0; j < students_number; j++)
{
students_rank[j][i] = find_rank_student(students_array[j][i],grades,students_number);