From 731e6094cdf3ae1127033c834954d26aa843d4b5 Mon Sep 17 00:00:00 2001 From: Raouak Haroun Date: Thu, 28 Mar 2019 11:53:50 +0100 Subject: [PATCH] commit du 28 masrs --- projet.c | 528 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------- 1 file changed, 472 insertions(+), 56 deletions(-) diff --git a/projet.c b/projet.c index e44fd8f..74ccadc 100644 --- a/projet.c +++ b/projet.c @@ -1,82 +1,498 @@ #include #include - - +#include typedef struct noeud { - int valeur; - struct noeud *gauche; - struct noeud *droite; + int valeur; + struct noeud *a; + struct noeud *b; + struct noeud *c; + struct noeud *d; + struct noeud *e; + struct noeud *f; + struct noeud *g; + struct noeud *h; + struct noeud *i; + struct noeud *j; + struct noeud *k; + struct noeud *l; + struct noeud *m; + struct noeud *n; + struct noeud *o; + struct noeud *p; + struct noeud *q; + struct noeud *r; + struct noeud *s; + struct noeud *t; + struct noeud *u; + struct noeud *v; + struct noeud *w; + struct noeud *x; + struct noeud *y; + struct noeud *z; } noeud ; - -void print_arbre(noeud *arbre) -{ - if (arbre==NULL) - printf("NULL\n"); - else if(arbre!=NULL) - { - printf("%d\n",arbre->valeur); - - if (arbre->gauche != NULL) - print_arbre(arbre->gauche); - // printf("\n");} - else if(arbre->gauche == NULL) - printf("NULL\t"); - - if (arbre->droite != NULL) - print_arbre(arbre->droite); - // printf("\n");} - else if (arbre->droite != NULL) - printf("NULL\t"); - } - +void insertion1(noeud ** arbre, int v){ + *arbre=(noeud*) malloc(sizeof(noeud)); + (*arbre)->valeur=v; + (*arbre)->a=NULL; + (*arbre)->b=NULL; + (*arbre)->c=NULL; + (*arbre)->d=NULL; + (*arbre)->e=NULL; + (*arbre)->f=NULL; + (*arbre)->g=NULL; + (*arbre)->h=NULL; + (*arbre)->i=NULL; + (*arbre)->j=NULL; + (*arbre)->k=NULL; + (*arbre)->l=NULL; + (*arbre)->m=NULL; + (*arbre)->n=NULL; + (*arbre)->o=NULL; + (*arbre)->p=NULL; + (*arbre)->q=NULL; + (*arbre)->r=NULL; + (*arbre)->s=NULL; + (*arbre)->t=NULL; + (*arbre)->u=NULL; + (*arbre)->v=NULL; + (*arbre)->w=NULL; + (*arbre)->x=NULL; + (*arbre)->y=NULL; + (*arbre)->z=NULL; + } -void insertion(noeud ** arbre, int v){ - if (*arbre==NULL) /* si le noeud n’existe pas, on le crée */ - { - *arbre=(noeud*) malloc(sizeof(noeud)); - (*arbre)->valeur=v; - (*arbre)->gauche=NULL; - (*arbre)->droite=NULL; - } +void insertion2(noeud ** arbre, int v){ + + { + + if (v==97) + insertion1(&(*arbre)->a,v); + + else if (v==98) + insertion1(&(*arbre)->b,v); + else if (v==99) + insertion1(&(*arbre)->c,v); + else if (v==99) + insertion1(&(*arbre)->c,v); + else if (v==100) + insertion1(&(*arbre)->d,v); + else if (v==101) + insertion1(&(*arbre)->e,v); + else if (v==102) + insertion1(&(*arbre)->f,v); + else if (v==103) + insertion1(&(*arbre)->g,v); + else if (v==104) + insertion1(&(*arbre)->h,v); + else if (v==105) + insertion1(&(*arbre)->i,v); + else if (v==106) + insertion1(&(*arbre)->j,v); + else if (v==107) + insertion1(&(*arbre)->k,v); + else if (v==108) + insertion1(&(*arbre)->l,v); + else if (v==109) + insertion1(&(*arbre)->m,v); + else if (v==110) + insertion1(&(*arbre)->n,v); + else if (v==111) + insertion1(&(*arbre)->o,v); + else if (v==112) + insertion1(&(*arbre)->p,v); + else if (v==113) + insertion1(&(*arbre)->q,v); + else if (v==114) + insertion1(&(*arbre)->r,v); + else if (v==115) + insertion1(&(*arbre)->s,v); + else if (v==116) + insertion1(&(*arbre)->t,v); + else if (v==117) + insertion1(&(*arbre)->u,v); + else if (v==118) + insertion1(&(*arbre)->v,v); + else if (v==119) + insertion1(&(*arbre)->w,v); + else if (v==120) + insertion1(&(*arbre)->x,v); + else if (v==121) + insertion1(&(*arbre)->y,v); + else if (v==122) + insertion1(&(*arbre)->z,v); + + + } } -// else -// { -// if (v>(*arbre)->valeur) -void insertionD(noeud ** arbre, int v){ - insertion(&(*arbre)->droite,v); /* aller a droite */ } -// else -void insertionG(noeud ** arbre, int v){ - insertion(&(*arbre)->gauche,v); /* aller a gauche */ } - - - -int main(){ +void remplissage(noeud ** arbre, FILE *fichier){ + int i; + char ch[20]; + fscanf(fichier,"%s",&ch); + int n=strlen(ch); + insertion1(&(*arbre),(int)ch[0]); + for (i=1;i