commit dd25f1dd5e80e672ff4b1c31953d390302c818a9
Author: mathis <mathis.contact@gmail.com>
Date:   Wed Sep 18 10:42:02 2024 +0200

    init commit

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..62c8935
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea/
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..425ff28
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.29)
+project(algo_tri CXX)
+
+set(CMAKE_CXX_STANDARD 20)
+
+add_subdirectory(sort_lib)
+add_subdirectory(src)
diff --git a/data/fic10 b/data/fic10
new file mode 100644
index 0000000..50176b9
--- /dev/null
+++ b/data/fic10
@@ -0,0 +1,11 @@
+10
+2
+8
+5
+6
+1
+4
+7
+0
+3
+9
\ No newline at end of file
diff --git a/data/fic100 b/data/fic100
new file mode 100644
index 0000000..b5c0e00
--- /dev/null
+++ b/data/fic100
@@ -0,0 +1,101 @@
+100
+2
+60
+96
+20
+19
+41
+74
+55
+4
+42
+35
+11
+35
+93
+25
+85
+87
+27
+38
+55
+75
+91
+98
+18
+57
+14
+54
+59
+41
+46
+93
+71
+26
+99
+8
+22
+27
+21
+10
+72
+25
+30
+27
+44
+78
+24
+83
+56
+33
+26
+85
+2
+84
+52
+32
+16
+14
+63
+57
+79
+66
+10
+22
+19
+70
+12
+85
+65
+91
+83
+39
+88
+8
+51
+63
+17
+93
+76
+74
+38
+11
+28
+24
+79
+99
+11
+23
+82
+35
+1
+48
+68
+82
+95
+99
+98
+3
+24
+79
+23
diff --git a/sort_lib/CMakeLists.txt b/sort_lib/CMakeLists.txt
new file mode 100644
index 0000000..b02d467
--- /dev/null
+++ b/sort_lib/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_library(sort_lib STATIC
+        data.cpp
+        data.h
+)
\ No newline at end of file
diff --git a/sort_lib/data.cpp b/sort_lib/data.cpp
new file mode 100644
index 0000000..93bb22c
--- /dev/null
+++ b/sort_lib/data.cpp
@@ -0,0 +1,207 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <unistd.h>
+#include <string.h>
+#include "data.h"
+
+
+
+/* -------------------------------------------------------------------------- */
+/* f_lire_data                                                                */
+/* int * f_lire_data(char *fichier, int *n);                                  */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant les  entiers  lus  dans le fichier texte   */
+/* dans le fichier texte de nom [fichier]                                     */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [fichier] : nom du fichier texte contenant les donn�es entieres        */
+/*                 premi�re ligne   : nombre [n] d'�l�ments � lire            */
+/*                 lignes suivantes : les [n] entiers � lire                  */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [n]       : nombre entier d'�l�ments lus                               */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]       : tableau de type int o� sont stock�s les entiers lus        */
+/* -------------------------------------------------------------------------- */
+
+   int *f_lire_data(char *fichier, int *n)
+   {
+      int i;
+      FILE *f;
+      int *tab;
+   
+   /* Ouverture du fichier en lecture */
+      f = fopen(fichier, "rt");
+      if (f == NULL)
+      {
+         printf("\n\nLecture <f_lire_data> :\nOuverture du fichier %s impossible\n\n", fichier);
+         exit(1);
+      }
+   
+   
+   /* Lecture du nombre d'�l�ments � lire */ 
+      fscanf (f, "%d\n", n);
+   
+   
+   /* Allocation de la m�moire n�cessaire */
+      tab = (int *) calloc(*n, sizeof(int));
+   
+   /* Lecture des n �l�ments */
+      for (i = 0; i < *n; i++)
+         fscanf (f, "%d\n", &tab[i]);
+   
+      fclose(f);
+      return(tab);
+   }
+
+
+/* -------------------------------------------------------------------------- */
+/* f_ecrire_data                                                              */
+/* void f_ecrire_data(char *fichier, int *t, int n)                           */
+/*                                                                            */
+/* Ecrire les [n] �l�ments de type entier du tableau [t] dans un fichier de   */
+/* type texte de nom [fichier]                                                */
+/*                 premi�re ligne   : nombre [n] d'�l�ments � lire            */
+/*                 lignes suivantes : les [n] entiers de [t]                  */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [fichier] : nom du fichier                                             */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [n] : nombre d'entiers du tableau                                      */
+/*                                                                            */
+/* -------------------------------------------------------------------------- */
+
+   void f_ecrire_data(char * fichier, int *t, int n)
+   {
+      FILE *f;
+      int i;
+   
+   /* Ouverture du fichier en �criture*/
+      f = fopen(fichier, "wt");
+      if (f == NULL)
+      {
+         printf("\n\nEcriture <f_ecrire_data> :\nOuverture du fichier %s impossible\n\n", fichier);
+         exit(1);
+      }
+   
+      fprintf(f, "%d\n", n);
+   
+      for (i = 0; i < n; i++)
+         fprintf(f, "%d\n", t[i]);
+   
+      fclose(f);
+   }
+
+
+/* -------------------------------------------------------------------------- */
+/* ecrire_data                                                                */
+/* void ecrire_data(int *t, int n)                                            */
+/*                                                                            */
+/* Ecrire les [n] �l�ments de type entier du tableau [t]  sur stdout          */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [n] : nombre d'entiers du tableau                                      */
+/*                                                                            */
+/* -------------------------------------------------------------------------- */
+
+   void ecrire_data(int *t, int n)
+   {
+      int i;
+   
+      printf("\n");
+      for (i = 0; i < n; i++)
+         printf("%d\n", t[i]);
+      printf("\n");
+   }
+
+/* -------------------------------------------------------------------------- */
+/* data_triee                                                                 */
+/* int *data_triee(int n)                                                     */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant les  [n] premiers entiers  dans l'ordre    */
+/* et sans ex-aequo                                                           */
+/*                                                                            */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [n]   : nombre d'entiers du tableau � cr�er                            */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]   : tableau d'entiers                                              */
+/* -------------------------------------------------------------------------- */
+
+   int *data_triee(int n)
+   {
+      int i;
+      int *t;
+   
+      t = (int *) calloc(n, sizeof(int));
+   
+      for (i = 0; i < n; i++)
+         t[i]  = i;
+   
+      return t;
+   }
+	
+	
+/* -------------------------------------------------------------------------- */
+/* data_triee_inverse                                                         */
+/* int *data_triee_inverse(int n)                                             */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant les  [n] premiers entiers  dans l'ordre    */
+/* inverse et sans ex-aequo                                                   */
+/*                                                                            */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [n]   : nombre d'entiers du tableau � cr�er                            */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]   : tableau d'entiers                                              */
+/* -------------------------------------------------------------------------- */
+
+   int *data_triee_inverse(int n)
+   {
+      int i;
+      int *t;
+      t = (int *) calloc(n, sizeof(int));
+   
+      for (i = 0; i < n; i++)
+         t[n-1-i]  = i;
+   
+      return t;
+   }
+
+
+/* -------------------------------------------------------------------------- */
+/* random_data                                                                */
+/* int *random_data(int n)                                                    */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant [n] nombres entiers al�atoires             */
+/*                                                                            */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [n]   : nombre d'entiers du tableau � cr�er                            */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]   : tableau d'entiers                                              */
+/* -------------------------------------------------------------------------- */
+
+   int *random_data(int n)
+   {
+      int i;
+      int pid;
+      int *t;
+   
+      pid = getpid ();
+      srand(pid);
+   
+      t = (int *) calloc(n, sizeof(int));
+   
+      for (i = 0; i < n; i++)
+         t[i]  = 1+(int) ((double) n *rand()/(RAND_MAX+1.0));
+   
+      return t;
+   }
+
diff --git a/sort_lib/data.h b/sort_lib/data.h
new file mode 100644
index 0000000..cc7a104
--- /dev/null
+++ b/sort_lib/data.h
@@ -0,0 +1,125 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <unistd.h>
+#include <string.h>
+
+
+
+
+/* -------------------------------------------------------------------------- */
+/* f_lire_data                                                                */
+/* int * f_lire_data(char *fichier, int *n);                                  */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant les  entiers  lus  dans le fichier texte   */
+/* dans le fichier texte de nom [fichier]                                     */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [fichier] : nom du fichier texte contenant les donn�es entieres        */
+/*                 premi�re ligne   : nombre [n] d'�l�ments � lire            */
+/*                 lignes suivantes : les [n] entiers � lire                  */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [n]       : nombre entier d'�l�ments lus                               */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]       : tableau de type int o� sont stock�s les entiers lus        */
+/* -------------------------------------------------------------------------- */
+
+int * f_lire_data(char *fichier, int *n);
+
+
+
+
+/* -------------------------------------------------------------------------- */
+/* f_ecrire_data                                                              */
+/* void f_ecrire_data(char *fichier, int *t, int n)                           */
+/*                                                                            */
+/* Ecrire les [n] �l�ments de type entier du tableau [t] dans un fichier de   */
+/* type texte de nom [fichier]                                                */
+/*                 premi�re ligne   : nombre [n] d'�l�ments � lire            */
+/*                 lignes suivantes : les [n] entiers de [t]                  */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [fichier] : nom du fichier                                             */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [n] : nombre d'entiers du tableau                                      */
+/*                                                                            */
+/* -------------------------------------------------------------------------- */
+
+void   f_ecrire_data(char *fichier, int *t, int n); 
+
+
+
+/* -------------------------------------------------------------------------- */
+/* ecrire_data                                                                */
+/* void ecrire_data(int *t, int n)                                            */
+/*                                                                            */
+/* Ecrire les [n] �l�ments de type entier du tableau [t]  sur stdout          */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [n] : nombre d'entiers du tableau                                      */
+/*                                                                            */
+/* -------------------------------------------------------------------------- */
+
+void   ecrire_data(int *t, int n);
+
+
+
+/* -------------------------------------------------------------------------- */
+/* data_triee                                                                 */
+/* int *data_triee(int n)                                                     */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant les  [n] premiers entiers  dans l'ordre    */
+/* et sans ex-aequo                                                           */
+/*                                                                            */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [n]   : nombre d'entiers du tableau � cr�er                            */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]   : tableau d'entiers                                              */
+/* -------------------------------------------------------------------------- */
+
+int * data_triee(int n);
+
+
+
+/* -------------------------------------------------------------------------- */
+/* data_triee_inverse                                                         */
+/* int *data_triee_inverse(int n)                                             */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant les  [n] premiers entiers  dans l'ordre    */
+/* inverse et sans ex-aequo                                                   */
+/*                                                                            */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [n]   : nombre d'entiers du tableau � cr�er                            */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]   : tableau d'entiers                                              */
+/* -------------------------------------------------------------------------- */
+
+int * data_triee_inverse(int n);
+
+
+
+/* -------------------------------------------------------------------------- */
+/* random_data                                                                */
+/* int *random_data(int n)                                                    */
+/*                                                                            */
+/* Cr�er un tableau [t]  contenant [n] nombres entiers al�atoires             */
+/*                                                                            */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [n]   : nombre d'entiers du tableau � cr�er                            */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [t]   : tableau d'entiers                                              */
+/* -------------------------------------------------------------------------- */
+
+int * random_data(int n);
+
+
+
diff --git a/sort_lib/tris.c b/sort_lib/tris.c
new file mode 100644
index 0000000..918eee0
--- /dev/null
+++ b/sort_lib/tris.c
@@ -0,0 +1,150 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <unistd.h>
+#include <string.h>
+#include "tris.h"
+
+
+/* -------------------------------------------------------------------------- */
+/* echanger                                                                   */
+/* void echanger(int *t, int n1, int n2)                                      */
+/*                                                                            */
+/* Echanger les �l�ments d'indice [n1] et [n2] du tableau d'entiers [t]       */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t]  : tableau d'entiers                                               */
+/*   - [n1] : indice                                                          */
+/*   - [n2] : indice                                                          */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [t]  : tableau d'entiers                                               */
+/*                                                                            */
+/* -------------------------------------------------------------------------- */
+
+   void echanger(int *t, int n1, int n2)  
+   {
+      int inter;
+   
+      inter = t[n1];
+      t[n1] =  t[n2];
+      t[n2] = inter;
+   }
+
+
+
+/* -------------------------------------------------------------------------- */
+/* tri_[algo_tri]                                                             */
+/* void tri_[algo_tri] (int *t, int n, structSondes *complexite)             */
+/*                                                                            */
+/* Trier le tableau d'entiers [t] � [n] �l�ments                              */
+/* [algo_tri] : bulle_naif, bulle_bool, bulle_opt, selection, insertion       */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [n] : nombre d'entiers du tableau                                      */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [t] : tableau d'entiers                                                */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [sondes] : structure r�sultat des sondes sur l'algorithme         */
+/*            sondes.nb_comparaisons                                     */
+/*            sondes.nb_echanges                                         */
+/*            sondes.nb_copies                                           */
+/* -------------------------------------------------------------------------- */
+
+   structSondes tri_bulle_naif(int *t, int n)
+   {
+      int i, j;
+      structSondes sondes = {0, 0, 0};
+   	
+     
+      return sondes;
+   }
+
+
+
+   structSondes tri_bulle_bool(int *t, int n)
+   {
+   // A faire : utilisation d'un drapeau (bool�en) qui teste que les donn�es sont tri�es
+   // en une lecture des donn�es
+   
+
+      structSondes sondes = {0, 0, 0};
+   
+      return sondes;
+   }
+	
+	
+
+   structSondes tri_bulle_opt(int *t, int n)
+   {
+   // A faire : on teste l'endroit du dernier �change pour modifier la boucle principale.
+   // Si le dernier �change est entre t_0 et t_1 alors on a termin�.
+      
+      structSondes sondes = {0, 0, 0};
+   
+
+      return sondes;
+   }
+
+
+
+
+
+
+
+
+   structSondes tri_selection(int *t, int n)
+   {  
+
+      structSondes sondes = {0, 0, 0};
+  
+      return sondes;   
+   }
+
+
+
+   structSondes tri_insertion(int *t, int n)
+   {
+
+      structSondes sondes = {0, 0, 0};
+   
+      return sondes;
+   }
+
+
+
+
+/* -------------------------------------------------------------------------- */
+/* tri_rapide                                                                 */
+/* void tri_rapide (int *t, int gauche, int droite, structSondes *complexite)*/
+/*                                                                            */
+/* Trier la portion du tableau d'entiers [t] comprise entre les indices       */
+/* [gauche] et [droite]                                                       */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [gauche] : indice gauche                                               */
+/*   - [droit] : indice droit                                                */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [t] : tableau d'entiers                                                */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [sondes] : structure r�sultat des sondes sur l'algorithme              */
+/*            sondes.nb_comparaisons                                     */
+/*            sondes.nb_echanges                                         */
+/*            sondes.nb_copies                                           */
+/* -------------------------------------------------------------------------- */
+
+   structSondes tri_rapide(int *t, int gauche, int droite)
+   {
+   
+
+      structSondes sondes = {0, 0, 0};
+  
+      return sondes;			
+   
+   }
diff --git a/sort_lib/tris.h b/sort_lib/tris.h
new file mode 100644
index 0000000..b2846f9
--- /dev/null
+++ b/sort_lib/tris.h
@@ -0,0 +1,92 @@
+
+/* Divers */
+#define TRUE 1
+#define FALSE 0
+
+
+
+/* El�ments d'analyse  */
+   typedef struct
+   {
+      long int nb_echanges;
+      long int nb_comparaisons;
+		long int nb_copies;
+   } structSondes;
+
+
+
+/* -------------------------------------------------------------------------- */
+/* echanger                                                                   */
+/* void echanger(int *t, int n1, int n2)                                      */
+/*                                                                            */
+/* Echanger les �l�ments d'indice [n1] et [n2] du tableau d'entiers [t]       */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t]  : tableau d'entiers                                               */
+/*   - [n1] : indice                                                          */
+/*   - [n2] : indice                                                          */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [t]  : tableau d'entiers                                               */
+/*                                                                            */
+/* -------------------------------------------------------------------------- */
+
+   void echanger(int *t, int n1, int n2);
+
+
+/* Algorithmes de tris */
+
+/* -------------------------------------------------------------------------- */
+/* tri_[algo_tri]                                                             */
+/* int tri_[algo_tri] (int *t, int n, structSondes *complexite)              */
+/*                                                                            */
+/* Trier le tableau d'entiers [t] � [n] �l�ments                              */
+/* [algo_tri] : bulle_naif, bulle_bool, bulle_opt, selection, insertion       */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [n] : nombre d'entiers du tableau                                      */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [t] : tableau d'entiers                                                */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [sondes] : structure r�sultat des sondes sur l'algorithme              */
+/*            complexite->nb_comparaisons                                     */
+/*            complexite->nb_echanges                                         */
+/*            complexite->nb_copies                                           */
+/* -------------------------------------------------------------------------- */
+
+   structSondes tri_bulle_naif(int *t, int n);
+   structSondes tri_bulle_bool(int *t, int n);
+   structSondes tri_bulle_opt(int *t, int n);
+
+   structSondes tri_insertion(int *t, int n);
+   structSondes tri_selection(int *t, int n);
+	
+	
+/* -------------------------------------------------------------------------- */
+/* tri_[algo_tri]                                                             */
+/* int tri_rapide (int *t, int gauche, int droite, structSondes *complexite) */
+/*                                                                            */
+/* Trier la portion du tableau d'entiers [t] comprise entre les indices       */
+/* [gauche] et [droite]                                                       */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*   - [t] : tableau d'entiers                                                */
+/*   - [gauche] : indice gauche                                               */
+/*   - [gauche] : indice droit                                                */
+/*                                                                            */
+/* Modifications :                                                            */
+/*   - [t] : tableau d'entiers                                                */
+/*                                                                            */
+/* Sorties :                                                                  */
+/*   - [sondes] : structure r�sultat des sondes sur l'algorithme              */
+/*            complexite->nb_comparaisons                                     */
+/*            complexite->nb_echanges                                         */
+/*            complexite->nb_copies                                           */
+/* -------------------------------------------------------------------------- */
+
+   structSondes tri_rapide(int *t, int gauche, int droite);
+
+
diff --git a/sort_lib/utilisation.c b/sort_lib/utilisation.c
new file mode 100644
index 0000000..72185d8
--- /dev/null
+++ b/sort_lib/utilisation.c
@@ -0,0 +1,348 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <unistd.h>
+#include <string.h>
+#include "tris.h"
+#include "data.h"
+
+
+/* Type des donn�es � trier */
+#define UNKNOWN  0
+#define FICHIER 1
+#define RANDOM  2
+#define TRIE    3
+#define TRIE_INVERSE 4
+
+
+/* Type de tri � utiliser */
+/* Num�ro XY, X pour la famille, Y pour la version */
+#define BULLE_NAIF 11
+#define BULLE_BOOL 12
+#define BULLE_OPT  13 
+#define SELECTION  2
+#define INSERTION  3
+#define TRIRAPIDE  4
+
+
+
+/* -------------------------------------------------------------------------- */
+/* analyse_complexite                                                         */
+/* void analyse_complexite(complexiteDef *complexite, char * tri)             */
+/*                                                                            */
+/* Afficher les diff�rentes options du programme [nom]                        */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*        [complexite] : le r�sultat en terme de complexit� du tri            */
+/*        [tri] : le nom du tri                                               */
+/*        [n]   : le nombre d'�l�ments tri�s                                  */
+/* -------------------------------------------------------------------------- */
+
+   void analyse_complexite(structSondes sondes, char *tri, int n)
+   {
+      printf("\nAnalyse de la complexite du tri %s de %d entiers\n", tri, n);
+      printf("\t  nombre de comparaisons = %ld\n", sondes.nb_comparaisons);
+      printf("\t  nombre de copies       = %ld\n", sondes.nb_copies); 
+      printf("\t  nombre d'�changes      = %ld\n", sondes.nb_echanges); 
+   }
+
+
+
+/* -------------------------------------------------------------------------- */
+/* aide                                                                       */
+/* int aide(char * nom)                                                       */
+/*                                                                            */
+/* Afficher les diff�rentes options du programme [nom]                        */
+/*                                                                            */
+/* Entr�es :                                                                  */
+/*        [nom] : le nom de l'ex�cutable                                      */
+/* -------------------------------------------------------------------------- */
+
+   void aide(char *nom)
+   {
+      printf("\nUtilisation :\n\n  %s [options]\n", nom);
+   
+      printf("\nOptions :\n");
+      printf("\n[1] Pour les donn�es (des entiers):\n");
+      printf("\n  - lues dans un Fichier texte : -f nom_fichier\n");
+      printf("\n    o� nom_fichier est le nom d'un fichier texte de la forme\n");
+      printf("\n      nombre_elements");
+      printf("\n      entier1");
+      printf("\n      entier2");
+      printf("\n      ...");
+      printf("\n      entiern");
+      printf("\n");
+      printf("\n   - cr�es Al�atoirement   : -a nombre_elements\n");
+      printf("\n    o� nombre_elements est le nombre d'�l�ments du tableau cr��\n");
+      printf("\n");
+      printf("\n   - d�j� tri�es (Meilleur des Cas) : -mc nombre_elements\n");
+      printf("\n    o� nombre_elements est le nombre d'�l�ments du tableau cr��\n");
+      printf("\n");
+      printf("\n   - tri�es dans l'ordre inverse (Pire des Cas) : -pc nombre_elements\n");
+      printf("\n    o� nombre_elements est le nombre d'�l�ments du tableau cr��\n");
+      printf("\n");
+      printf("\n   - pour sauver la tableau initial dans un fichier texte : -si nom_fichier\n");
+      printf("\n    o� nom_fichier est le nom d'un fichier\n");
+      printf("\n");
+      printf("\n   - pour sauver la tableau final dans un fichier texte : -sf nom_fichier\n");
+      printf("\n    o� nom_fichier est le nom d'un fichier\n");
+      printf("\n");
+      printf("\n[2] Pour l'algorithme de Tri :");
+      printf("\n  -t algo\n");
+      printf("\n    o� algo = bulle_naif, bulle_bool, bulle_opt, selection, insertion, rapide\n");
+      printf("\n");
+      printf("\nExemples :\n\n");
+      printf("\n  donn�es lues dans le fichier tab1.dat et tri�es avec bulle na�f");
+      printf("\n    -f tab1.dat -t bulle_naif\n");
+      printf("\n    -t bulle_naif -f tab1.dat\n\n");
+      printf("\n  10 donn�es cr��es al�atoirement et tri�es avec insertion");
+      printf("\n    -a 10 -t insertion\n");
+      printf("\n    -t insertion -a 10\n\n");
+      printf("\n  8 donn�es dans l'ordre inverse, tri�es avec tri rapide, sauv�es dans tab1.dat");
+      printf("\n    -pc 8 -t rapide -sf tab1.dat\n");
+      printf("\n");
+      printf("\n[3]  Pour afficher ou non les tableaux : ");
+		printf("\n    -v   (par d�faut on n'affiche pas)\n");
+      printf("\n");
+   }
+
+
+
+
+
+/* -------------------------------------------------------------------------- */
+
+   int main(int argn, char *argv[])
+   {
+      int type_data;
+      int type_tri;
+      int sauvegarde_tableau_initial;
+      int sauvegarde_tableau_final;
+      int affichage_tableaux;
+      int n = 0;
+      char *fichier_lecture_tableau_initial, *fichier_sauvegarde_tableau_initial, *fichier_sauvegarde_tableau_final;
+      int *tab;
+      int i;
+   
+   
+      structSondes sondes = {0, 0, 0};
+   
+      if (argn == 1) 
+      {
+         aide(argv[0]);
+         exit(1);
+      }
+   
+      type_data = UNKNOWN;
+      type_tri = UNKNOWN;
+      sauvegarde_tableau_initial = FALSE;
+      sauvegarde_tableau_final = FALSE;
+      affichage_tableaux = FALSE;
+   
+      for ( i = 1; i < argn; i+=2 )
+      {
+      	// choix des donn�es � trier et des sauvegardes �ventuelles du tableau initial et final
+         if (strcmp("-f", argv[i]) == 0)
+         {
+            fichier_lecture_tableau_initial = (char *) malloc(1 + strlen(argv[i+1]) * sizeof(char));
+            strcpy(fichier_lecture_tableau_initial, argv[i+1]);
+            type_data = FICHIER;
+            continue;
+         }
+      
+         if (strcmp("-si", argv[i]) == 0)
+         {
+            fichier_sauvegarde_tableau_initial = (char *) malloc(1 + strlen(argv[i+1]) * sizeof(char));
+            strcpy(fichier_sauvegarde_tableau_initial, argv[i+1]);
+            sauvegarde_tableau_initial = TRUE;
+            continue;
+         }
+      
+         if (strcmp("-sf", argv[i]) == 0)
+         {
+            fichier_sauvegarde_tableau_final = (char *) malloc(1 + strlen(argv[i+1]) * sizeof(char));
+            strcpy(fichier_sauvegarde_tableau_final, argv[i+1]);
+            sauvegarde_tableau_final = TRUE;
+            continue;
+         }
+      
+         if (strcmp("-a", argv[i]) == 0)
+         {
+            n = atoi(argv[i+1]);
+            type_data = RANDOM;
+            continue;
+         }
+      
+         if (strcmp("-mc", argv[i]) == 0)
+         {
+            n = atoi(argv[i+1]);
+            type_data = TRIE;
+            continue;
+         }
+      
+         if (strcmp("-pc", argv[i]) == 0)
+         {
+            n = atoi(argv[i+1]);
+            type_data = TRIE_INVERSE;
+            continue;
+         }
+
+      
+       	// choix de l'algorithme de tri
+         if (strcmp("-t", argv[i]) == 0)
+         {
+            if (strcmp("bulle_naif", argv[i+1]) == 0)
+               type_tri = BULLE_NAIF;
+            
+            else if (strcmp("bulle_bool", argv[i+1]) == 0)
+               type_tri = BULLE_BOOL;
+            
+            else if (strcmp("bulle_opt", argv[i+1]) == 0)
+               type_tri = BULLE_OPT;
+            
+            else if (strcmp("selection", argv[i+1]) == 0)
+               type_tri = SELECTION;
+            
+            else if (strcmp("insertion", argv[i+1]) == 0)
+               type_tri = INSERTION;
+            
+            else if (strcmp("rapide", argv[i+1]) == 0)
+               type_tri = TRIRAPIDE;
+            	
+            else 
+            {
+					printf("\t le tri demand� < %s >  n'existe pas \n", argv[i+1]);
+               aide(argv[0]);
+               exit(1);
+            }
+            continue;
+         }
+
+      
+       	// choix de la visualisation (affichage) du tableau initial et final
+         if (strcmp("-v", argv[i]) == 0)
+         {
+            affichage_tableaux = TRUE;
+            i--;
+            continue;
+         }
+      	
+			printf("\t l'option demand�e < %s >  n'existe pas \n", argv[i]);
+         aide(argv[0]);	
+			exit(1);
+      }
+   
+
+   
+      switch(type_data)
+      {
+         case TRIE:
+            {
+               tab = data_triee(n);
+               printf("Tableau initial tri� (meilleur des cas)");
+               break;
+            }
+         
+         case TRIE_INVERSE:
+            {
+               tab = data_triee_inverse(n);
+               printf("Tableau intial tri� en ordre inverse (pire des cas)");
+               break;
+            }
+         case FICHIER:
+            {
+               tab = f_lire_data(fichier_lecture_tableau_initial, &n);
+               printf("Tableau initial lu dans %s", fichier_lecture_tableau_initial);
+               break;
+            }
+         case RANDOM:
+            {
+               tab = random_data(n);
+               printf("Tableau initial al�atoire");
+               break;
+            }
+         case UNKNOWN:
+            aide(argv[0]);
+            exit(1);
+      }
+
+
+   	if (n < 1) {
+			printf("\t le nombre d'�l�ments � trier est incorrect : %d \n", n);
+         aide(argv[0]);	
+			exit(1);
+		}
+      
+      if (sauvegarde_tableau_initial == TRUE)
+         f_ecrire_data(fichier_sauvegarde_tableau_initial, tab, n);
+   
+   
+      if (affichage_tableaux == TRUE) {
+         printf("\n");
+         ecrire_data(tab,  n);
+      }
+   
+      switch(type_tri)
+      {
+         case BULLE_NAIF: 
+            sondes = tri_bulle_naif(tab, n);
+            if (affichage_tableaux == TRUE) {
+               printf("Tableau tri� (bulle na�f)\n");
+               ecrire_data(tab,  n);
+            }
+            analyse_complexite(sondes, "bulle na�f", n);
+            break;
+         case BULLE_BOOL: 
+            sondes = tri_bulle_bool(tab, n);
+            if (affichage_tableaux == TRUE) {
+               printf("Tableau tri� (bulle bool)\n");
+               ecrire_data(tab,  n);
+            }
+            analyse_complexite(sondes, "bulle bool", n);
+            break;
+         case BULLE_OPT: 
+            sondes = tri_bulle_opt(tab, n);
+            if (affichage_tableaux == TRUE) {
+               printf("Tableau tri� (bulle opt)\n");
+               ecrire_data(tab,  n);
+            }
+            analyse_complexite(sondes, "bulle opt", n);
+            break;
+         case SELECTION:
+            sondes = tri_selection(tab, n);
+            if (affichage_tableaux == TRUE) {
+               printf("Tableau tri� (selection)\n");
+               ecrire_data(tab,  n);
+            }
+            analyse_complexite(sondes, "selection", n);
+            break;
+         case INSERTION:
+            sondes = tri_insertion(tab, n);
+            if (affichage_tableaux == TRUE) {
+               printf("Tableau tri� (insertion)\n");
+               ecrire_data(tab,  n);
+            }
+            analyse_complexite(sondes, "insertion", n);
+            break;
+         case TRIRAPIDE:
+            sondes = tri_rapide(tab, 0, n-1);
+            if (affichage_tableaux == TRUE) {
+               printf("Tableau tri� (rapide)\n");
+               ecrire_data(tab,  n);
+            }
+            analyse_complexite(sondes, "rapide", n);
+            break;
+         case UNKNOWN:
+            aide(argv[0]);
+            exit(1);
+      }
+   
+   
+      if (sauvegarde_tableau_final == TRUE)
+         f_ecrire_data(fichier_sauvegarde_tableau_final, tab, n);
+   
+      printf("\n");
+      return 0;
+   }
+
+
diff --git a/src/AlgoBench.cpp b/src/AlgoBench.cpp
new file mode 100644
index 0000000..ff50465
--- /dev/null
+++ b/src/AlgoBench.cpp
@@ -0,0 +1,32 @@
+#include "AlgoBench.h"
+
+BenchResult AlgoBench::bench(std::function<Probes(const std::vector<int>&)> alg_func, int test_depth) {
+    BenchResult results{};
+
+    auto best_data = to_vector(data_triee(test_depth)); // Already sorted
+    auto mid_data = to_vector(random_data(test_depth)); // Random sorted
+    auto worst_data = to_vector(data_triee_inverse(test_depth)); // Sorted inversed
+
+    auto tc = TimeCounter{};
+
+    tc.start();
+    Probes res = alg_func(best_data);
+    tc.stop();
+    results.best_case_time = tc.get_us();
+    results.best_case = res;
+
+    tc.start();
+    res = alg_func(mid_data);
+    tc.stop();
+    results.mid_case_time = tc.get_us();
+    results.mid_case = res;
+
+    tc.start();
+    res = alg_func(worst_data);
+    tc.stop();
+    results.worst_case_time = tc.get_us();
+    results.worst_case = res;
+
+    return results;
+}
+
diff --git a/src/AlgoBench.h b/src/AlgoBench.h
new file mode 100644
index 0000000..944e6dc
--- /dev/null
+++ b/src/AlgoBench.h
@@ -0,0 +1,30 @@
+#ifndef ALGO_TRI_ALGOBENCH_H
+#define ALGO_TRI_ALGOBENCH_H
+
+#include <functional>
+#include <vector>
+
+#include "utils.hpp"
+#include "data.h"
+#include "TimeCounter.h"
+
+struct BenchResult {
+    long worst_case_time;
+    long mid_case_time;
+    long best_case_time;
+
+    Probes worst_case;
+    Probes mid_case;
+    Probes best_case;
+};
+
+class AlgoBench{
+public:
+    AlgoBench() = default;
+    ~AlgoBench() = default;
+
+    BenchResult bench(std::function<Probes(const std::vector<int>&)> alg_func, int test_depth);
+};
+
+
+#endif //ALGO_TRI_ALGOBENCH_H
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..b36a3ad
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_executable(sort_utils
+        main.cpp
+        utils.hpp
+        AlgoBench.cpp
+        AlgoBench.h
+        sort_functions.h
+        sort_function.cpp
+        TimeCounter.cpp
+        TimeCounter.h
+)
+
+target_link_libraries(sort_utils PUBLIC sort_lib)
+target_include_directories(sort_utils PUBLIC ${CMAKE_SOURCE_DIR}/sort_lib)
\ No newline at end of file
diff --git a/src/TimeCounter.cpp b/src/TimeCounter.cpp
new file mode 100644
index 0000000..4cff255
--- /dev/null
+++ b/src/TimeCounter.cpp
@@ -0,0 +1,15 @@
+#include "TimeCounter.h"
+
+void TimeCounter::start() {
+    m_start = std::chrono::high_resolution_clock::now();
+}
+
+void TimeCounter::stop() {
+    m_stop = std::chrono::high_resolution_clock::now();
+    m_duration = std::chrono::duration_cast<std::chrono::microseconds>(m_stop - m_start).count();
+}
+
+long TimeCounter::get_us() const {
+    return m_duration;
+}
+
diff --git a/src/TimeCounter.h b/src/TimeCounter.h
new file mode 100644
index 0000000..a0518e0
--- /dev/null
+++ b/src/TimeCounter.h
@@ -0,0 +1,25 @@
+#ifndef TIMECOUNTER_H
+#define TIMECOUNTER_H
+
+#include <chrono>
+
+class TimeCounter {
+public:
+    TimeCounter() = default;
+    ~TimeCounter() = default;
+
+    void start();
+    void stop();
+
+    long get_us() const;
+
+private:
+    std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
+    std::chrono::time_point<std::chrono::high_resolution_clock> m_stop;
+
+    long m_duration;
+};
+
+
+
+#endif //TIMECOUNTER_H
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..c53df15
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,5 @@
+#include <iostream>
+
+int main(int argc, char* argv[]) {
+
+}
diff --git a/src/sort_function.cpp b/src/sort_function.cpp
new file mode 100644
index 0000000..a09398a
--- /dev/null
+++ b/src/sort_function.cpp
@@ -0,0 +1,19 @@
+#include "AlgoBench.h"
+
+Probes tri_bulle(const std::vector<int>& data) {
+    Probes probes{0, 0, 0};
+
+    for(int i = data.size(); i <= 0; i--) {
+        for(int j = 0; j < i; j++) {
+
+            if(data[j] > data[j + 1]) {
+                swap(data, i, j);
+
+                probes.nComp++;
+                probes.nSwaps++;
+            }
+        }
+    }
+
+    return probes;
+}
diff --git a/src/sort_functions.h b/src/sort_functions.h
new file mode 100644
index 0000000..599c09d
--- /dev/null
+++ b/src/sort_functions.h
@@ -0,0 +1,11 @@
+#ifndef ALGO_TRI_SORT_FUNCTIONS_H
+#define ALGO_TRI_SORT_FUNCTIONS_H
+
+#include <vector>
+#include "utils.hpp"
+
+Probes tri_bulle(const std::vector<int>& data);
+Probes tri_bulle_flagged(const std::vector<int>& data);
+Probes tri_bulle_opti(std::vector<int>& data);
+
+#endif //ALGO_TRI_SORT_FUNCTIONS_H
diff --git a/src/utils.hpp b/src/utils.hpp
new file mode 100644
index 0000000..05d51bc
--- /dev/null
+++ b/src/utils.hpp
@@ -0,0 +1,22 @@
+#ifndef ALGO_TRI_UTILS_HPP
+#define ALGO_TRI_UTILS_HPP
+
+#include <vector>
+
+struct Probes {
+    int nComp;
+    int nCopy;
+    int nSwaps;
+};
+
+template<class T>
+std::vector<T> to_vector(T* c_array) {
+    return std::vector<T>(std::begin(c_array), std::end(c_array));
+}
+
+template<class T>
+void swap(const std::vector<T>& src, int a, int b) {
+    std::swap(src.begin() + a, src.begin() + b);
+}
+
+#endif //ALGO_TRI_UTILS_HPP