diff --git a/.DS_Store b/.DS_Store index c50808a229292826f092c6c5b242bd22c37b29e8..1f2672ca2ca7eae2a0f1c0aade22fda47818e7f9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/myTP/.DS_Store b/TP/.DS_Store similarity index 70% rename from myTP/.DS_Store rename to TP/.DS_Store index ca64d0137e4facf36131a396aab0c82bf69740bd..5f0fbbbb40b2b340fe181fe4e4dc696d90e5cbb9 100644 Binary files a/myTP/.DS_Store and b/TP/.DS_Store differ diff --git a/myTP/._.DS_Store b/TP/._.DS_Store similarity index 100% rename from myTP/._.DS_Store rename to TP/._.DS_Store diff --git a/myTP/Stack_C/stack b/TP/Stack_C/stack similarity index 100% rename from myTP/Stack_C/stack rename to TP/Stack_C/stack diff --git a/myTP/Stack_C/stack.c b/TP/Stack_C/stack.c similarity index 100% rename from myTP/Stack_C/stack.c rename to TP/Stack_C/stack.c diff --git a/myTP/Stack_dynamic_C/a.out b/TP/Stack_dynamic_C/a.out similarity index 100% rename from myTP/Stack_dynamic_C/a.out rename to TP/Stack_dynamic_C/a.out diff --git a/myTP/Stack_dynamic_C/stack_dyn.c b/TP/Stack_dynamic_C/stack_dyn.c similarity index 100% rename from myTP/Stack_dynamic_C/stack_dyn.c rename to TP/Stack_dynamic_C/stack_dyn.c diff --git a/myTP/TP1/app b/TP/TP1/app similarity index 100% rename from myTP/TP1/app rename to TP/TP1/app diff --git a/myTP/TP1/exercice1.c b/TP/TP1/exercice1.c similarity index 100% rename from myTP/TP1/exercice1.c rename to TP/TP1/exercice1.c diff --git a/myTP/TP1/exercice4.c b/TP/TP1/exercice4.c similarity index 100% rename from myTP/TP1/exercice4.c rename to TP/TP1/exercice4.c diff --git a/myTP/TP1/exo4 b/TP/TP1/exo4 similarity index 100% rename from myTP/TP1/exo4 rename to TP/TP1/exo4 diff --git a/myTP/TP10/exo1 b/TP/TP10/exo1 similarity index 100% rename from myTP/TP10/exo1 rename to TP/TP10/exo1 diff --git a/myTP/TP10/exo1.c b/TP/TP10/exo1.c similarity index 100% rename from myTP/TP10/exo1.c rename to TP/TP10/exo1.c diff --git a/myTP/TP10/exo2.c b/TP/TP10/exo2.c similarity index 100% rename from myTP/TP10/exo2.c rename to TP/TP10/exo2.c diff --git a/myTP/TP11/.DS_Store b/TP/TP11/.DS_Store similarity index 100% rename from myTP/TP11/.DS_Store rename to TP/TP11/.DS_Store diff --git a/myTP/TP11/exo1 b/TP/TP11/exo1 similarity index 100% rename from myTP/TP11/exo1 rename to TP/TP11/exo1 diff --git a/myTP/TP11/exo1.c b/TP/TP11/exo1.c similarity index 100% rename from myTP/TP11/exo1.c rename to TP/TP11/exo1.c diff --git a/myTP/TP11/exo1.dSYM/Contents/Info.plist b/TP/TP11/exo1.dSYM/Contents/Info.plist similarity index 100% rename from myTP/TP11/exo1.dSYM/Contents/Info.plist rename to TP/TP11/exo1.dSYM/Contents/Info.plist diff --git a/myTP/TP11/exo1.dSYM/Contents/Resources/DWARF/exo1 b/TP/TP11/exo1.dSYM/Contents/Resources/DWARF/exo1 similarity index 100% rename from myTP/TP11/exo1.dSYM/Contents/Resources/DWARF/exo1 rename to TP/TP11/exo1.dSYM/Contents/Resources/DWARF/exo1 diff --git a/myTP/TP11/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml b/TP/TP11/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml similarity index 100% rename from myTP/TP11/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml rename to TP/TP11/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml diff --git a/myTP/TP11/exo2 b/TP/TP11/exo2 similarity index 100% rename from myTP/TP11/exo2 rename to TP/TP11/exo2 diff --git a/myTP/TP11/exo2.c b/TP/TP11/exo2.c similarity index 100% rename from myTP/TP11/exo2.c rename to TP/TP11/exo2.c diff --git a/myTP/TP11/exo2.dSYM/Contents/Info.plist b/TP/TP11/exo2.dSYM/Contents/Info.plist similarity index 100% rename from myTP/TP11/exo2.dSYM/Contents/Info.plist rename to TP/TP11/exo2.dSYM/Contents/Info.plist diff --git a/myTP/TP11/exo2.dSYM/Contents/Resources/DWARF/exo2 b/TP/TP11/exo2.dSYM/Contents/Resources/DWARF/exo2 similarity index 100% rename from myTP/TP11/exo2.dSYM/Contents/Resources/DWARF/exo2 rename to TP/TP11/exo2.dSYM/Contents/Resources/DWARF/exo2 diff --git a/myTP/TP11/exo2.dSYM/Contents/Resources/Relocations/aarch64/exo2.yml b/TP/TP11/exo2.dSYM/Contents/Resources/Relocations/aarch64/exo2.yml similarity index 100% rename from myTP/TP11/exo2.dSYM/Contents/Resources/Relocations/aarch64/exo2.yml rename to TP/TP11/exo2.dSYM/Contents/Resources/Relocations/aarch64/exo2.yml diff --git a/myTP/TP11/test.c b/TP/TP11/test.c similarity index 100% rename from myTP/TP11/test.c rename to TP/TP11/test.c diff --git a/myTP/TP12/.DS_Store b/TP/TP12/.DS_Store similarity index 100% rename from myTP/TP12/.DS_Store rename to TP/TP12/.DS_Store diff --git a/myTP/TP12/a.out b/TP/TP12/a.out similarity index 100% rename from myTP/TP12/a.out rename to TP/TP12/a.out diff --git a/myTP/TP12/a.out.dSYM/Contents/Info.plist b/TP/TP12/a.out.dSYM/Contents/Info.plist similarity index 100% rename from myTP/TP12/a.out.dSYM/Contents/Info.plist rename to TP/TP12/a.out.dSYM/Contents/Info.plist diff --git a/myTP/TP12/a.out.dSYM/Contents/Resources/DWARF/a.out b/TP/TP12/a.out.dSYM/Contents/Resources/DWARF/a.out similarity index 100% rename from myTP/TP12/a.out.dSYM/Contents/Resources/DWARF/a.out rename to TP/TP12/a.out.dSYM/Contents/Resources/DWARF/a.out diff --git a/myTP/TP12/annuary b/TP/TP12/annuary similarity index 100% rename from myTP/TP12/annuary rename to TP/TP12/annuary diff --git a/myTP/TP12/exo1 b/TP/TP12/exo1 similarity index 100% rename from myTP/TP12/exo1 rename to TP/TP12/exo1 diff --git a/myTP/TP12/exo1.c b/TP/TP12/exo1.c similarity index 100% rename from myTP/TP12/exo1.c rename to TP/TP12/exo1.c diff --git a/myTP/TP12/exo1.dSYM/Contents/Info.plist b/TP/TP12/exo1.dSYM/Contents/Info.plist similarity index 100% rename from myTP/TP12/exo1.dSYM/Contents/Info.plist rename to TP/TP12/exo1.dSYM/Contents/Info.plist diff --git a/myTP/TP12/exo1.dSYM/Contents/Resources/DWARF/exo1 b/TP/TP12/exo1.dSYM/Contents/Resources/DWARF/exo1 similarity index 100% rename from myTP/TP12/exo1.dSYM/Contents/Resources/DWARF/exo1 rename to TP/TP12/exo1.dSYM/Contents/Resources/DWARF/exo1 diff --git a/myTP/TP12/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml b/TP/TP12/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml similarity index 100% rename from myTP/TP12/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml rename to TP/TP12/exo1.dSYM/Contents/Resources/Relocations/aarch64/exo1.yml diff --git a/myTP/TP12/test.c b/TP/TP12/test.c similarity index 100% rename from myTP/TP12/test.c rename to TP/TP12/test.c diff --git a/myTP/TP13/exo1 b/TP/TP13/exo1 similarity index 100% rename from myTP/TP13/exo1 rename to TP/TP13/exo1 diff --git a/myTP/TP13/exo1.c b/TP/TP13/exo1.c similarity index 100% rename from myTP/TP13/exo1.c rename to TP/TP13/exo1.c diff --git a/myTP/TP13/exo2 b/TP/TP13/exo2 similarity index 100% rename from myTP/TP13/exo2 rename to TP/TP13/exo2 diff --git a/myTP/TP13/exo2.c b/TP/TP13/exo2.c similarity index 100% rename from myTP/TP13/exo2.c rename to TP/TP13/exo2.c diff --git a/myTP/TP15/Main b/TP/TP15/Main similarity index 100% rename from myTP/TP15/Main rename to TP/TP15/Main diff --git a/myTP/TP15/Makefile b/TP/TP15/Makefile similarity index 100% rename from myTP/TP15/Makefile rename to TP/TP15/Makefile diff --git a/myTP/TP15/calculator.c b/TP/TP15/calculator.c similarity index 100% rename from myTP/TP15/calculator.c rename to TP/TP15/calculator.c diff --git a/myTP/TP15/executable b/TP/TP15/executable similarity index 100% rename from myTP/TP15/executable rename to TP/TP15/executable diff --git a/myTP/TP15/fractions.c b/TP/TP15/fractions.c similarity index 100% rename from myTP/TP15/fractions.c rename to TP/TP15/fractions.c diff --git a/myTP/TP15/fractions.h b/TP/TP15/fractions.h similarity index 100% rename from myTP/TP15/fractions.h rename to TP/TP15/fractions.h diff --git a/myTP/TP15/test b/TP/TP15/test similarity index 100% rename from myTP/TP15/test rename to TP/TP15/test diff --git a/myTP/TP15/test.c b/TP/TP15/test.c similarity index 100% rename from myTP/TP15/test.c rename to TP/TP15/test.c diff --git a/TP/TP18/hash.c b/TP/TP18/hash.c new file mode 100644 index 0000000000000000000000000000000000000000..676d74d37897dc2edbfadf9b5090b9c3a99147a9 --- /dev/null +++ b/TP/TP18/hash.c @@ -0,0 +1,79 @@ +#include <stdio.h> +#include <stdlib.h> +#include "hash.h" + + +int hash(val,length){ + + + for (int i = 0; i < strlen(c); ++i) { + val = (43 * val + c[i]) % length; + } + return (val % length); +} + +hm_t* hm_create(int capacity){ + + hm_t* hash_map = (hm_t*)malloc(sizeof(hm_t)); + + hash_map->length = capacity; + + return hash_map; +} + +void hm_destroy(hm_t* hm){ + + + for (int i= 0;i< hm->length;i++){ + + hm_t* current_entry = hm->entries[i]; + + while(current_entry != NULL){ + + current_entry = hm->entries[i]; + free(current_entry); + } + } + + free(hm->entries); + + free(hm); + +} + +void hm_set(hm_t* hm, char* key, char* value){ + + +} + + +char* hm_get(hm_t* hm, char* key){ + + int index = hash(key,hm->length); + + for (int i ?=) + hm_t* current_entry = hm->entries[i]; + +} + + + + + + + +int main (){ + + int capacity = 100; // Capacité de la table de hachage + + // Création d'une nouvelle table de hachage + hm_t* hash_map = hm_create(capacity); + + // Utilisation de la table de hachage... + + // Libération de la mémoire allouée pour la table de hachage lorsque vous avez terminé + free(hash_map); + + return 0; + +} \ No newline at end of file diff --git a/TP/TP18/hash.h b/TP/TP18/hash.h new file mode 100644 index 0000000000000000000000000000000000000000..da1709a1c280010bc512173cab87c20dce978c16 --- /dev/null +++ b/TP/TP18/hash.h @@ -0,0 +1,39 @@ + +typedef struct { + struct entry_t **entries; + int length; +} hm_t; + +typedef struct entry_t { + char *key; + char *value; + struct entry_t *next; +}entry_t; + +// création d'un pointeur vers une hm +hm_t* hm_create(int capacity); +// destruction de la hm et libération de la mémoire +void hm_destroy(hm_t* hm); +// insère la paire key-value dans la hm. si key est déjà présente +// écraser value dans la hm. La clé et la valeur sont stockées +// dans de nouveau espaces mémoires alloués par la fonction + +void hm_set(hm_t* hm, char* key, char* value); +// retourne la valeur associé à la clé, key +// dans un espace mémoire alloué à strcet effet +char* hm_get_alloc(hm_t* hm, char* key); +// retourne la valeur associé à la clé, key +// retourne le pointeur dans la structure hm_t +char* hm_get(hm_t* hm, char* key); +// retire une clé de la hm +void hm_rm(hm_t* hm, char* key); +// teste si une clé se trouve dans la hm +bool hm_is_present(hm_t* hm, char* key); +// affiche le contenu de la hm +void hm_print(hm_t* hm); +// sauvegarde les pairs clé-valeur contenues de la table de hachage dans un fichier texte +// au format <key>;<value> +void hm_save(hm_t *hm, char *filename); +// charge les pairs clé-valeur dans une table de hachage depuis les +// lignes d'un fichier texte dont le format est <key>;<value> +hm_t *hm_load(char *filename); \ No newline at end of file diff --git a/myTP/TP2/exo1 b/TP/TP2/exo1 similarity index 100% rename from myTP/TP2/exo1 rename to TP/TP2/exo1 diff --git a/myTP/TP2/exo1.c b/TP/TP2/exo1.c similarity index 100% rename from myTP/TP2/exo1.c rename to TP/TP2/exo1.c diff --git a/myTP/TP2/exo2 b/TP/TP2/exo2 similarity index 100% rename from myTP/TP2/exo2 rename to TP/TP2/exo2 diff --git a/myTP/TP2/exo2.c b/TP/TP2/exo2.c similarity index 100% rename from myTP/TP2/exo2.c rename to TP/TP2/exo2.c diff --git a/myTP/TP2/exo3 b/TP/TP2/exo3 similarity index 100% rename from myTP/TP2/exo3 rename to TP/TP2/exo3 diff --git a/myTP/TP2/exo3.c b/TP/TP2/exo3.c similarity index 100% rename from myTP/TP2/exo3.c rename to TP/TP2/exo3.c diff --git a/myTP/TP3/exo1 b/TP/TP3/exo1 similarity index 100% rename from myTP/TP3/exo1 rename to TP/TP3/exo1 diff --git a/myTP/TP3/exo1.c b/TP/TP3/exo1.c similarity index 100% rename from myTP/TP3/exo1.c rename to TP/TP3/exo1.c diff --git a/myTP/TP4/exo1 b/TP/TP4/exo1 similarity index 100% rename from myTP/TP4/exo1 rename to TP/TP4/exo1 diff --git a/myTP/TP4/exo1.c b/TP/TP4/exo1.c similarity index 100% rename from myTP/TP4/exo1.c rename to TP/TP4/exo1.c diff --git a/myTP/TP4/exo2 b/TP/TP4/exo2 similarity index 100% rename from myTP/TP4/exo2 rename to TP/TP4/exo2 diff --git a/myTP/TP4/exo2.c b/TP/TP4/exo2.c similarity index 100% rename from myTP/TP4/exo2.c rename to TP/TP4/exo2.c diff --git a/myTP/TP5/exo1 b/TP/TP5/exo1 similarity index 100% rename from myTP/TP5/exo1 rename to TP/TP5/exo1 diff --git a/myTP/TP5/exo1.c b/TP/TP5/exo1.c similarity index 100% rename from myTP/TP5/exo1.c rename to TP/TP5/exo1.c diff --git a/myTP/TP6/exo1 b/TP/TP6/exo1 similarity index 100% rename from myTP/TP6/exo1 rename to TP/TP6/exo1 diff --git a/myTP/TP6/exo1.c b/TP/TP6/exo1.c similarity index 100% rename from myTP/TP6/exo1.c rename to TP/TP6/exo1.c diff --git a/myTP/TP7/exo1 b/TP/TP7/exo1 similarity index 100% rename from myTP/TP7/exo1 rename to TP/TP7/exo1 diff --git a/myTP/TP7/exo1.c b/TP/TP7/exo1.c similarity index 100% rename from myTP/TP7/exo1.c rename to TP/TP7/exo1.c diff --git a/myTP/TP8/algorithmique-programmation-soir-2023-2024-public.code-workspace b/TP/TP8/algorithmique-programmation-soir-2023-2024-public.code-workspace similarity index 100% rename from myTP/TP8/algorithmique-programmation-soir-2023-2024-public.code-workspace rename to TP/TP8/algorithmique-programmation-soir-2023-2024-public.code-workspace diff --git a/myTP/TP8/exo1 b/TP/TP8/exo1 similarity index 100% rename from myTP/TP8/exo1 rename to TP/TP8/exo1 diff --git a/myTP/TP8/exo1.c b/TP/TP8/exo1.c similarity index 100% rename from myTP/TP8/exo1.c rename to TP/TP8/exo1.c diff --git a/myTP/TP8/exo2.c b/TP/TP8/exo2.c similarity index 100% rename from myTP/TP8/exo2.c rename to TP/TP8/exo2.c diff --git a/myTP/TP9/exo1 b/TP/TP9/exo1 similarity index 100% rename from myTP/TP9/exo1 rename to TP/TP9/exo1 diff --git a/myTP/TP9/exo1.c b/TP/TP9/exo1.c similarity index 100% rename from myTP/TP9/exo1.c rename to TP/TP9/exo1.c diff --git a/myTP/TP9/exo2.c b/TP/TP9/exo2.c similarity index 100% rename from myTP/TP9/exo2.c rename to TP/TP9/exo2.c diff --git a/myTP/exo1 b/TP/exo1 similarity index 100% rename from myTP/exo1 rename to TP/exo1 diff --git a/myTP/exos/dilatation b/TP/exos/dilatation similarity index 100% rename from myTP/exos/dilatation rename to TP/exos/dilatation diff --git a/myTP/exos/dilatation.c b/TP/exos/dilatation.c similarity index 100% rename from myTP/exos/dilatation.c rename to TP/exos/dilatation.c diff --git a/myTP/exos/exo1 b/TP/exos/exo1 similarity index 100% rename from myTP/exos/exo1 rename to TP/exos/exo1 diff --git a/myTP/exos/exo1.c b/TP/exos/exo1.c similarity index 100% rename from myTP/exos/exo1.c rename to TP/exos/exo1.c diff --git a/myTP/read_file/my_file.txt b/TP/read_file/my_file.txt similarity index 100% rename from myTP/read_file/my_file.txt rename to TP/read_file/my_file.txt diff --git a/myTP/read_file/test b/TP/read_file/test similarity index 100% rename from myTP/read_file/test rename to TP/read_file/test diff --git a/myTP/read_file/test.c b/TP/read_file/test.c similarity index 100% rename from myTP/read_file/test.c rename to TP/read_file/test.c diff --git a/myTP/test.c b/TP/test.c similarity index 100% rename from myTP/test.c rename to TP/test.c