Skip to content
Snippets Groups Projects
Commit 5e5a7435 authored by lucas.toniutti's avatar lucas.toniutti
Browse files

Initialisation du dépot git + quelque fonctions mais elle ne marche pas bien

parents
No related branches found
No related tags found
No related merge requests found
Makefile 0 → 100644
CC=gcc -Wall -Wextra -lm -O3
executable: tri.o main.o
$(CC) $^ -o $@
tri.o: tri.c tri.h
$(CC) -c $<
main.o: main.c
$(CC) -c $<
clean:
rm -f *.o tri
rebuild: clean tri
main.c 0 → 100644
#include "tri.h"
#include <stdbool.h>
bool desc(int32_t a, int32_t b){
return a < b;
}
int main(){
int size = 15;
int32_t array[size];
int32_t sorted[size];
for (int32_t i = 0; i < size; i++) {
array[i] = rand() % 100;
}
for (int i=0; i<size; i++){
printf("%4d\n", array[i]);
}
printf("//////////////\n");
triBulle(sorted, array, size, desc);
for (int i=0; i<size; i++){
printf("%4d\n", sorted[i]);
}
}
tri.c 0 → 100644
#include <stdlib.h>
#include <stdbool.h>
#include "tri.h"
void triBulle(int32_t sorted[], const int32_t *const orig, int32_t nitems, bool (*comp)(int32_t, int32_t)){
copierTableau(sorted, orig, nitems);
int tmp;
for(int i=0; i < nitems-1; i++){
for(int j=0; i < (nitems-i-1); j++){
//Décroissant <
if (sorted[j] > sorted[j+1]){
tmp = sorted[j];
sorted[j] = sorted[j+1];
sorted[j+1] = tmp;
}
}
}
}
void triRapide(int32_t sorted[], const int32_t *const orig, int32_t nitems, bool (*comp)(int32_t, int32_t)){
}
void triPile(int32_t sorted[], const int32_t *const orig, int32_t nitems, bool (*comp)(int32_t, int32_t)){
}
void copierTableau(int32_t *copie, const int32_t *const orig, int32_t size){
for (int32_t i = 0; i<size; i++){
copie[i] = orig[i];
}
}
\ No newline at end of file
tri.h 0 → 100644
#ifndef SORT_H_
#define SORT_H_
#include <stdlib.h>
#include <stdbool.h>
void triBulle(int32_t sorted[], const int32_t *const orig, int32_t nitems, bool (*comp)(int32_t, int32_t));
void triRapide(int32_t sorted[], const int32_t *const orig, int32_t nitems, bool (*comp)(int32_t, int32_t));
void triPile(int32_t sorted[], const int32_t *const orig, int32_t nitems, bool (*comp)(int32_t, int32_t));
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment