arbre.c 1.13 KB
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>


typedef struct arbre{
    char val;
    struct arbre *suite[26];
    bool finmot; //1 si fin de mot
}Arbre;

typedef struct dico {
    Arbre *alpha[26];
}Dico;





void arbre_vide(struct arbre ** pt_arbre)
{
	*pt_arbre = NULL;
}

bool est_vide(struct arbre *arbre)
{
	return arbre==NULL;
}

bool fin_de_mot(struct arbre *arbre)
{
	return arbre->finmot;
}
void initialise_dico(struct arbre * pt_arbre,char val){
    
    
    
}

void cons_dico(struct dico **pt_dico,char val){
    Dico *mondico=malloc(sizeof(struct dico));
    mondico->alpha[val-97]->val=val; // (ascii)->a = 97
    for(int i=0;i<26;i++){
        mondico->alpha[val-97]->suite[i]=NULL;        
    }
    mondico->alpha[val-97]->finmot=false;
    (*pt_dico)=mondico;
}

void cons_arbre(struct arbre **pt_arbre,char val){
    struct arbre *monarbre=malloc(sizeof(struct arbre));
    monarbre->suite[val-97]->val=val; // (ascii)->a = 97
    
}



void ini_dico(struct dico * pt_dico){
    for(int i=0;i<26;i++){
        cons_dico(&pt_dico,97+i);        
    }
}
    





int main (){
    
    
    
    
    
    return 0;
}