diff --git a/Yûki/arbre_de_codage/liste.c b/Yûki/arbre_de_codage/liste.c new file mode 100644 index 0000000..8527bd2 --- /dev/null +++ b/Yûki/arbre_de_codage/liste.c @@ -0,0 +1,56 @@ +#include +#include +#include "liste.h" + +Freq creer_liste_vide(){ + return NULL; +} + +int est_liste_vide(Freq l){ + return(l==NULL); +} + +Freq ajouter(int nb, char lettre, Freq l){ + Occ * tmp; + tmp=malloc(sizeof(Occ)); + tmp->nb=nb; + tmp->lettre=lettre; + tmp->suiv=l; + return tmp; +} + +char tete(Freq l){ + assert(!est_liste_vide(l)); + return(l->lettre); +} + +Freq queue(Freq l){ + assert(!est_liste_vide(l)); + return(l->suiv); +} + +void liberer_liste(Freq l){ + if(!est_liste_vide(l)){ + liberer_liste(queue(l)); + free(l); + } +} + +Freq liberer_maillon(Freq l){ + assert(!est_liste_vide(l)); + Occ * tmp = l->suiv; + free(l); + return tmp; +} + +int rechercher(char lettre,Freq l){ + if(est_liste_vide(l)){ + return 0; + } + else if(lettre==tete(l)){ + return 1; + } + else{ + return rechercher(lettre,queue(l)); + } +} \ No newline at end of file diff --git a/Yûki/arbre_de_codage/liste.h b/Yûki/arbre_de_codage/liste.h new file mode 100644 index 0000000..511087d --- /dev/null +++ b/Yûki/arbre_de_codage/liste.h @@ -0,0 +1,20 @@ +#ifndef __LISTE_OCCURENCE__ +#define __LISTE_OCCURENCE__ +struct zoccurence{ + int nb; + char lettre; + struct zoccurence *suiv; +}; +typedef struct zoccurence Occ; +typedef struct zoccurence * Freq; + +Freq creer_liste_vide(); +int est_liste_vide(Freq l); +Freq ajouter(int nb, char lettre, Freq l); +int tete(Freq l); +Freq queue(Freq l); +void liberer_liste(Freq l); +Freq liberer_maillon(Freq l); +int rechercher(char lettre, Freq l); + +#endif \ No newline at end of file diff --git a/Yûki/arbre_de_codage/main.c b/Yûki/arbre_de_codage/main_compress.c similarity index 62% rename from Yûki/arbre_de_codage/main.c rename to Yûki/arbre_de_codage/main_compress.c index 7148bf4..e2a3885 100644 --- a/Yûki/arbre_de_codage/main.c +++ b/Yûki/arbre_de_codage/main_compress.c @@ -1,15 +1,9 @@ #include #include "arbre_binaire.h" -struct zoccurence{ - int nb; - char lettre; -}; -typedef struct zoccurence occ; -typedef struct zoccurence * freq; - int main () { + freq Test[5]={{7,'a'},{1,'c'},{3,'g'},{1,'t'},{1,'END'}}; } /* diff --git a/Yûki/gestion_des_fichiers/bit_a_bit.c b/Yûki/gestion_des_fichiers/bit_a_bit.c index 8346047..2a9cb70 100644 --- a/Yûki/gestion_des_fichiers/bit_a_bit.c +++ b/Yûki/gestion_des_fichiers/bit_a_bit.c @@ -7,14 +7,21 @@ void binaire(unsigned int n, char s[]); int main(int argc, char **argv){ FILE *file; char buffer; - int cursor,c; + int cursor,c,i; file=fopen("text.txt","rb"); + char text_b[5][BIN_MAX+1]; + i=0; // EOF : End Of File while((c=fgetc(file))!=EOF){ char sb[BIN_MAX+1]; - binaire(32,sb); + binaire(c,sb); printf("%s\n",sb); } + for(i=0;i<5;i++){ + for(int j=0;j=BIN_MAX); s[BIN_MAX]= '\0'; @@ -37,4 +43,8 @@ void binaire(unsigned int n, char s[]){ i++; } } -} + int k; + for(k=BIN_MAX-i-1;k>=0;k--){ + s[k]= '0'; + } +} \ No newline at end of file diff --git a/Yûki/gestion_des_fichiers/bit_a_bit.exe b/Yûki/gestion_des_fichiers/bit_a_bit.exe index c573037..05e56fd 100644 Binary files a/Yûki/gestion_des_fichiers/bit_a_bit.exe 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 index f25e7dc..9402861 100644 Binary files a/Yûki/gestion_des_fichiers/bit_a_bit.o and b/Yûki/gestion_des_fichiers/bit_a_bit.o differ diff --git a/Yûki/gestion_des_fichiers/gestion_fichiers.c b/Yûki/gestion_des_fichiers/gestion_fichiers.c new file mode 100644 index 0000000..a96bfd3 --- /dev/null +++ b/Yûki/gestion_des_fichiers/gestion_fichiers.c @@ -0,0 +1,4 @@ +/* + Fonctions liés à la gestion de fichiers + +*/ \ No newline at end of file diff --git a/Yûki/gestion_des_fichiers/gestion_fichiers.h b/Yûki/gestion_des_fichiers/gestion_fichiers.h new file mode 100644 index 0000000..c8aa5e3 --- /dev/null +++ b/Yûki/gestion_des_fichiers/gestion_fichiers.h @@ -0,0 +1,3 @@ +/* + Prototypes de gestion_fichiers.c + variables define + structure(s) +*/ \ No newline at end of file diff --git a/travaux_a_faire_projet_c.txt b/travaux_a_faire_projet_c.txt index 1c7f81b..52917a7 100644 --- a/travaux_a_faire_projet_c.txt +++ b/travaux_a_faire_projet_c.txt @@ -1,18 +1,45 @@ -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 +TRAVAUX : + 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 + 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 + 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é + + +FICHIERS A PREVOIR : + + Makefile + + main_compress.c + main_decompress.c + + GESTION DES FICHIERS : + - gestion_fichiers.h + - gestion_fichier.c + + ARBRE DE CODAGE : + - arbre_binaire.h + - arbre_binaire.c + (Utile pour stocker le nombre d'occurence d'un caractère) + - liste.h + - liste.c + + +INSTRUCTION A FAIRE PENDANT LE CODAGE : + - Commenter chaque fonction (ce qu'elle fait avec entrée et sortie) + - Commenter des parties non trivial (évident) + -EXTRACTION (DECOMPRESSION) : - - Fonction d'extraction d'un fichier texte depuis un fichier compressé \ No newline at end of file