diff --git a/Compression en codage de Huffman.pdf b/Compression en codage de Huffman.pdf new file mode 100644 index 0000000..4ad9116 Binary files /dev/null and b/Compression en codage de Huffman.pdf differ diff --git a/Yûki/README.md b/Yûki/README.md new file mode 100644 index 0000000..dfb98d4 --- /dev/null +++ b/Yûki/README.md @@ -0,0 +1,30 @@ +# Projet-C-Huffman +**Projet C Huffman commencé le 2 Décembre 2019 (Compression et décompression d'un fichier)**. + +*Collaborateurs : Yûki VACHOT, Guillaume XIUME, Wilfried VALLEE, Florian COQUILLAT*. + +## COMMENT COMMIT AVEC VISUAL STUDIO CODE : +*(Commit : soumettre, valider des fichiers)* + +1. Si ce n'est pas déjà fait télécharger **[Visual Studio Code](https://code.visualstudio.com/Download)** *(Windows, Linux ou Mac)*. +2. Créer un compte sur **[GitHub](https://github.com/)**. +3. Donner à **Yûki** votre nom de compte GitHub ou votre adresse e-mail associée (Je vous rajouterais au répertoire). +4. Véfifier si vous avez déjà **Git** avec un terminal en mettant `git --version`. + - Vérifier que vous avez une version supérieure à 2.0. + - Sinon télécharger **[Git](https://git-scm.com/downloads)**. +5. Aller sur VSCode puis ouvrez le dossier de votre projet *(CTRL + K ou O par défaut)*. +6. Aller dans l'onglet "Contrôle de Code Source" ![Img VSCode Contrôle de Code Source VSCode](https://cdn.vachot.fr/img/vscode_icon_controle_code_source_25x22.png) *(CTRL + MAJ + G par défaut)* . + - Note : vérifier que **Git est activé** dans les paramètres de Git sur VSCode. + - `Fichier -> Préférences -> Paramètres -> Utilisateur -> Extensions -> Git -> Enabled -> Yes or No` +7. Ouvrir votre dossier dans l'onglet "Contrôle de Code Source" si ce n'est pas déjà fait avec le petit bouton à sa droite. +8. Dans la partie haut gauche mettez un message clair pour définir le commit puis pressez sur Entrer. + - Le changement ne s'est pas encore effectué sur le dossier dans **GitHub**, il ne l'est que localement pour l'instant. Donc, il faut associer votre dossier au répertoire sur **GitHub** (Vous ne pourrez pas encore "push" vos changements). + +9. Ajouter le répertoire distant + - Ouvrir la palette de commande *(CTRL + MAJ + P par défaut)* + - Rechercher `Git Add Remote` et pressez entrer + - Mettez un nom pour vous afin de reconnaître le dépôt + - Puis mettez ce lien : **https://github.com/NyxiumYuuki/Projet-C-Huffman.git** + - Publier enfin vos changements en appuyant sur le bouton en bas à droite ![Img VSCode Publier Modifications](https://cdn.vachot.fr/img/vscode_icon_publish_modifications_25x21.png) *(Il faudra vous connecter à votre compte GitHub)* + - ***Félicitations vous avez enfin fait votre premier commit !*** +10. Vous pouvez maintenant voir les changements entre les différents fichiers, voir l'avancement des autres collaborateurs et vous pouvez aussi commit vos changements en répétant les **étapes 7 et 8** diff --git a/Yûki/Yûki/arbre_de_codage/Makefile b/Yûki/Yûki/arbre_de_codage/Makefile new file mode 100644 index 0000000..b2b339d --- /dev/null +++ b/Yûki/Yûki/arbre_de_codage/Makefile @@ -0,0 +1,19 @@ +CC = gcc +CCOPTS = -Wall + +all: main + +arbre_naire.o: arbre_naire.c arbre_naire.h + ${CC} ${CCOPTS} -c arbre_naire.c + +arbre_binaire.o: arbre_binaire.c arbre_binaire.h + ${CC} ${CCOPTS} -c arbre_binaire.c + +main.o: main.c + ${CC} ${CCOPTS} -c main.c + +main: main.o arbre_naire.o arbre_binaire.o + ${CC} ${CCOPTS} -o main main.o arbre_naire.o arbre_binaire.o + +clean: + rm *.o ; rm main diff --git a/Yûki/Yûki/arbre_de_codage/arbre_binaire.c b/Yûki/Yûki/arbre_de_codage/arbre_binaire.c new file mode 100644 index 0000000..051dad3 --- /dev/null +++ b/Yûki/Yûki/arbre_de_codage/arbre_binaire.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include "arbre_binaire.h" + +arbre creer_arbre_vide (void) +{ + return NULL ; +} + +arbre creer_arbre_huffman(Elt e, int p, arbre fg, arbre fd) +{ + noeud * tmp = malloc(sizeof(noeud)); + tmp->elt=e; + tmp->poids=p; + tmp->fils_gauche=fg; + tmp->fils_droit=fd; + return tmp; +} + +arbre fils_gauche(arbre a) +{ + assert(!est_arbre_vide(a)); + return a->fils_gauche; +} + +arbre fils_droit(arbre b) +{ + assert(!est_arbre_vide(b)); + return b->fils_droit; +} + +Elt racine(arbre a) +{ + assert(!est_arbre_vide(a)); + return a->elt; +} + +bool est_arbre_vide(arbre a) +{ + return (a == NULL) ; +} + +arbre creer_feuille(Elt e) +{ + return creer_arbre(e, creer_arbre_vide(), creer_arbre_vide()) ; +} + +bool est_feuille(arbre a) +{ + if (est_arbre_vide(a)) + return 0 ; + return (est_arbre_vide(a->fils_gauche) && est_arbre_vide(a->fils_droit)) ; +} + +void free_noeud(arbre a) +{ + assert(!est_arbre_vide(a)); + free(a); +} + +void free_arbre(arbre a) +{ + if(!est_arbre_vide(a)){ + free_arbre(fils_gauche(a)); + free_arbre(fils_droit(a)); + free(a); + } +} \ No newline at end of file diff --git a/Yûki/Yûki/arbre_de_codage/arbre_binaire.h b/Yûki/Yûki/arbre_de_codage/arbre_binaire.h new file mode 100644 index 0000000..beca338 --- /dev/null +++ b/Yûki/Yûki/arbre_de_codage/arbre_binaire.h @@ -0,0 +1,25 @@ +#ifndef __ARBRE_BINAIRE__ +#define __ARBRE_BINAIRE__ + +typedef char Elt; +typedef int bool; +struct znoeud { + Elt elt ; + int poids; + struct znoeud *fils_gauche; + struct znoeud *fils_droit; +}; +typedef struct znoeud noeud ; +typedef struct znoeud * arbre; + +arbre creer_arbre_vide(void); +arbre creer_arbre_huffman(Elt e, int p, arbre fg, arbre fd); +arbre fils_gauche(arbre a); +arbre fils_droit(arbre a); +Elt racine(arbre a); +bool est_arbre_vide(arbre a); + +arbre creer_feuille(Elt e) ; +bool est_feuille(arbre a) ; + +#endif diff --git a/Yûki/Yûki/arbre_de_codage/frequence_dapparition_char.c b/Yûki/Yûki/arbre_de_codage/frequence_dapparition_char.c new file mode 100644 index 0000000..0ec19e8 --- /dev/null +++ b/Yûki/Yûki/arbre_de_codage/frequence_dapparition_char.c @@ -0,0 +1,15 @@ +#include +#include + +struct zoccurence{ + int nb; + char lettre; +}; +typedef struct zoccurence occ; +typedef struct zoccurence * freq; + + + + + + diff --git a/Yûki/Yûki/arbre_de_codage/main.c b/Yûki/Yûki/arbre_de_codage/main.c new file mode 100644 index 0000000..4621c4d --- /dev/null +++ b/Yûki/Yûki/arbre_de_codage/main.c @@ -0,0 +1,24 @@ +#include +#include "arbre_binaire.h" + +struct zoccurence{ + int nb; + char lettre; +}; +typedef struct zoccurence occ; +typedef struct zoccurence * freq; + +int main () +{ + +} +/* + L est considéré comme ordonné +*/ +arbre huffman(arbre H, freq L[]) +{ + int i; + + printf(L[]->nb); + printf(L[]->lettre); +} \ No newline at end of file diff --git a/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.c b/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.c new file mode 100644 index 0000000..8346047 --- /dev/null +++ b/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.c @@ -0,0 +1,40 @@ +#include +#include +#define BIN_MAX 8 + +void binaire(unsigned int n, char s[]); + +int main(int argc, char **argv){ + FILE *file; + char buffer; + int cursor,c; + file=fopen("text.txt","rb"); + // EOF : End Of File + while((c=fgetc(file))!=EOF){ + char sb[BIN_MAX+1]; + binaire(32,sb); + printf("%s\n",sb); + } + fclose(file); + return 0; +} + +void binaire(unsigned int n, char s[]){ + /* + Décomposition binaire d'un entier (=BIN_MAX); + s[BIN_MAX]= '\0'; + int i,r; + i=0; + while(n!=0){ + r = n%2; + n = n/2; + if(0<=(BIN_MAX-i-1) && (BIN_MAX-i-1)<=BIN_MAX){ + if(r==0) s[BIN_MAX-i-1]= '0'; + else s[BIN_MAX-i-1]= '1'; + i++; + } + } +} diff --git a/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.exe b/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.exe new file mode 100644 index 0000000..c573037 Binary files /dev/null and b/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.exe differ diff --git a/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.o b/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.o new file mode 100644 index 0000000..f25e7dc Binary files /dev/null and b/Yûki/Yûki/gestion_des_fichiers/bit_a_bit.o differ diff --git a/Yûki/Yûki/gestion_des_fichiers/text.txt b/Yûki/Yûki/gestion_des_fichiers/text.txt new file mode 100644 index 0000000..402476b --- /dev/null +++ b/Yûki/Yûki/gestion_des_fichiers/text.txt @@ -0,0 +1 @@ +ABCDE \ No newline at end of file diff --git a/Yûki/arbre_de_codage/Makefile b/Yûki/arbre_de_codage/Makefile new file mode 100644 index 0000000..5f31453 --- /dev/null +++ b/Yûki/arbre_de_codage/Makefile @@ -0,0 +1,19 @@ +CC = gcc +CCOPTS = -Wall + +all: main + +arbre_naire.o: arbre_naire.c arbre_naire.h + ${CC} ${CCOPTS} -c arbre_naire.c + +arbre_binaire.o: arbre_binaire.c arbre_binaire.h + ${CC} ${CCOPTS} -c arbre_binaire.c + +main.o: main.c + ${CC} ${CCOPTS} -c main.c + +main: main.o arbre_naire.o arbre_binaire.o + ${CC} ${CCOPTS} -o main main.o arbre_naire.o arbre_binaire.o + +clean: + rm *.o ; rm main diff --git a/Yûki/arbre_de_codage/arbre_binaire.c b/Yûki/arbre_de_codage/arbre_binaire.c new file mode 100644 index 0000000..bae65d8 --- /dev/null +++ b/Yûki/arbre_de_codage/arbre_binaire.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include "arbre_binaire.h" + +arbre creer_arbre_vide (void) +{ + return NULL ; +} + +arbre creer_arbre_huffman(Elt e, int p, arbre fg, arbre fd) +{ + noeud * tmp = malloc(sizeof(noeud)); + tmp->elt=e; + tmp->poids=p; + tmp->fils_gauche=fg; + tmp->fils_droit=fd; + return tmp; +} + +arbre fils_gauche(arbre a) +{ + assert(!est_arbre_vide(a)); + return a->fils_gauche; +} + +arbre fils_droit(arbre b) +{ + assert(!est_arbre_vide(b)); + return b->fils_droit; +} + +Elt racine(arbre a) +{ + assert(!est_arbre_vide(a)); + return a->elt; +} + +bool est_arbre_vide(arbre a) +{ + return (a == NULL) ; +} + +arbre creer_feuille(Elt e) +{ + return creer_arbre(e, creer_arbre_vide(), creer_arbre_vide()) ; +} + +bool est_feuille(arbre a) +{ + if (est_arbre_vide(a)) + return 0 ; + return (est_arbre_vide(a->fils_gauche) && est_arbre_vide(a->fils_droit)) ; +} + +void free_noeud(arbre a) +{ + assert(!est_arbre_vide(a)); + free(a); +} + +void free_arbre(arbre a) +{ + if(!est_arbre_vide(a)){ + free_arbre(fils_gauche(a)); + free_arbre(fils_droit(a)); + free(a); + } +} \ No newline at end of file diff --git a/Yûki/arbre_de_codage/arbre_binaire.h b/Yûki/arbre_de_codage/arbre_binaire.h new file mode 100644 index 0000000..01de6e5 --- /dev/null +++ b/Yûki/arbre_de_codage/arbre_binaire.h @@ -0,0 +1,25 @@ +#ifndef __ARBRE_BINAIRE__ +#define __ARBRE_BINAIRE__ + +typedef char Elt; +typedef int bool; +struct znoeud { + Elt elt ; + int poids; + struct znoeud *fils_gauche; + struct znoeud *fils_droit; +}; +typedef struct znoeud noeud ; +typedef struct znoeud * arbre; + +arbre creer_arbre_vide(void); +arbre creer_arbre_huffman(Elt e, int p, arbre fg, arbre fd); +arbre fils_gauche(arbre a); +arbre fils_droit(arbre a); +Elt racine(arbre a); +bool est_arbre_vide(arbre a); + +arbre creer_feuille(Elt e) ; +bool est_feuille(arbre a) ; + +#endif diff --git a/Yûki/arbre_de_codage/frequence_dapparition_char.c b/Yûki/arbre_de_codage/frequence_dapparition_char.c new file mode 100644 index 0000000..9f185d3 --- /dev/null +++ b/Yûki/arbre_de_codage/frequence_dapparition_char.c @@ -0,0 +1,15 @@ +#include +#include + +struct zoccurence{ + int nb; + char lettre; +}; +typedef struct zoccurence occ; +typedef struct zoccurence * freq; + + + + + + diff --git a/Yûki/arbre_de_codage/main.c b/Yûki/arbre_de_codage/main.c new file mode 100644 index 0000000..7148bf4 --- /dev/null +++ b/Yûki/arbre_de_codage/main.c @@ -0,0 +1,24 @@ +#include +#include "arbre_binaire.h" + +struct zoccurence{ + int nb; + char lettre; +}; +typedef struct zoccurence occ; +typedef struct zoccurence * freq; + +int main () +{ + +} +/* + L est considéré comme ordonné +*/ +arbre huffman(arbre H, freq L[]) +{ + int i; + + printf(L[]->nb); + printf(L[]->lettre); +} \ No newline at end of file diff --git a/Yûki/gestion_des_fichiers/bit_a_bit.c b/Yûki/gestion_des_fichiers/bit_a_bit.c new file mode 100644 index 0000000..8346047 --- /dev/null +++ b/Yûki/gestion_des_fichiers/bit_a_bit.c @@ -0,0 +1,40 @@ +#include +#include +#define BIN_MAX 8 + +void binaire(unsigned int n, char s[]); + +int main(int argc, char **argv){ + FILE *file; + char buffer; + int cursor,c; + file=fopen("text.txt","rb"); + // EOF : End Of File + while((c=fgetc(file))!=EOF){ + char sb[BIN_MAX+1]; + binaire(32,sb); + printf("%s\n",sb); + } + fclose(file); + return 0; +} + +void binaire(unsigned int n, char s[]){ + /* + Décomposition binaire d'un entier (=BIN_MAX); + s[BIN_MAX]= '\0'; + int i,r; + i=0; + while(n!=0){ + r = n%2; + n = n/2; + if(0<=(BIN_MAX-i-1) && (BIN_MAX-i-1)<=BIN_MAX){ + if(r==0) s[BIN_MAX-i-1]= '0'; + else s[BIN_MAX-i-1]= '1'; + i++; + } + } +} diff --git a/Yûki/gestion_des_fichiers/bit_a_bit.exe b/Yûki/gestion_des_fichiers/bit_a_bit.exe new file mode 100644 index 0000000..c573037 Binary files /dev/null and b/Yûki/gestion_des_fichiers/bit_a_bit.exe differ diff --git a/Yûki/gestion_des_fichiers/bit_a_bit.o b/Yûki/gestion_des_fichiers/bit_a_bit.o new file mode 100644 index 0000000..f25e7dc Binary files /dev/null and b/Yûki/gestion_des_fichiers/bit_a_bit.o differ diff --git a/Yûki/gestion_des_fichiers/text.txt b/Yûki/gestion_des_fichiers/text.txt new file mode 100644 index 0000000..402476b --- /dev/null +++ b/Yûki/gestion_des_fichiers/text.txt @@ -0,0 +1 @@ +ABCDE \ No newline at end of file diff --git a/lorem_ipsum.txt b/lorem_ipsum.txt new file mode 100644 index 0000000..a400117 --- /dev/null +++ b/lorem_ipsum.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc auctor eros sed odio tristique pulvinar. Nam facilisis pellentesque cursus. Integer eu iaculis odio. Pellentesque dapibus metus sit amet ante tempor, in commodo nunc feugiat. Vestibulum ac facilisis nulla, bibendum sagittis mauris. Sed tincidunt imperdiet lorem ut scelerisque. Sed dapibus nulla quam, non tempus elit dictum eu.Etiam a lectus eu nulla feugiat lobortis. Suspendisse porta augue eros, vel convallis metus euismod eget. Curabitur maximus ligula eu lacus pellentesque, nec iaculis erat ultricies. Nulla bibendum tortor sed ex consectetur, quis accumsan arcu cursus. Ut finibus porttitor commodo. Cras pellentesque lorem eget neque pharetra molestie. Mauris ultricies molestie mattis. Etiam volutpat sit amet massa et congue. Nunc non venenatis nisl, sit amet finibus est. In vitae fermentum orci. Integer quis sem et est mollis aliquet. Mauris lacus arcu, aliquet non vulputate fringilla, pellentesque hendrerit mauris metus. \ No newline at end of file diff --git a/travaux_a_faire_projet_c.txt b/travaux_a_faire_projet_c.txt new file mode 100644 index 0000000..1c7f81b --- /dev/null +++ b/travaux_a_faire_projet_c.txt @@ -0,0 +1,18 @@ +GESTION DE FICHIERS : + - Structure Gérer les échanges avec le disque, mémorisant notamment l’état des échanges en cours + - Fonction Ouvrir un fichier binaire en lecture ou écriture + - Fonction Ecrire un bit dans un fichier binaire + - Fonction Lire un fichier binaire + - Fonction Fermer un fichier + +ARBRE DE CODAGE : + - Fonction Fréquence d'apparition des caractères dans un fichier + - tri quicksort + - Implémentation de l'algorithme de construction de l'arbre de codage (Module Arbres_Binaires) + - tri à bulle + +COMPRESSION : + - Fonction de compression d'un fichier texte dans un fichier binaire + +EXTRACTION (DECOMPRESSION) : + - Fonction d'extraction d'un fichier texte depuis un fichier compressé \ No newline at end of file