From 0c252f1e7fa343e5c15b951a67b9574180d9ef2f Mon Sep 17 00:00:00 2001 From: Raouak Haroun Date: Tue, 2 Apr 2019 15:58:00 +0200 Subject: [PATCH] commit du 2 avril --- projet.c | 1183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 1 file changed, 685 insertions(+), 498 deletions(-) diff --git a/projet.c b/projet.c index 74ccadc..e886c99 100644 --- a/projet.c +++ b/projet.c @@ -1,498 +1,685 @@ -#include -#include -#include - -typedef struct noeud -{ - 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 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 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); - - - } -} - -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 +#include +#include +#include + + +typedef struct noeud{ + int valeur; + struct noeud *lettre[26]; +} noeud ; + +noeud *getTreeBranch(noeud * arbre,int i){ + return arbre->lettre[i]; +} + +void create_and_initialize_node(noeud ** parbre, int v){ + + *parbre=malloc(sizeof(noeud)); + (*parbre)->valeur=v; + int i; + for(i=0;i<26;i++) + (*parbre)->lettre[i]=NULL; + +} + +void remplissage(noeud ** parbre, FILE *fichier){ + int i; + char ch[128]; + fscanf(fichier,"%s",&ch); + int n=strlen(ch); + create_and_initialize_node(parbre,ch[0]); + for(i=1;ivaleur) + return 1; + else + return 0; +} +/* +bool repeat(noeud * arbre,char ch[]){ + int cpt=0; + int n=strlen(ch); + int i; + for(i=0;ia,ch[i]); + } + if(cpt==n) + return 1; + else + return 0; */ + + + + + + + +//void verification(noeud ** arbre, FILE *fichier){ + // char ch[20] + +// do{ + // existe(&(*arbre),ch); + //}while(fscanf(file,"%s",&ch)==1); + +int main(){ + + + + noeud *ArbreA = NULL; + noeud *ArbreB = NULL; + noeud *ArbreC = NULL; + noeud *ArbreD = NULL; + noeud *ArbreE = NULL; + noeud *ArbreF = NULL; + noeud *ArbreG = NULL; + noeud *ArbreH = NULL; + noeud *ArbreI = NULL; + noeud *ArbreJ = NULL; + noeud *ArbreK = NULL; + noeud *ArbreL = NULL; + noeud *ArbreM = NULL; + noeud *ArbreN = NULL; + noeud *ArbreO = NULL; + noeud *ArbreP = NULL; + noeud *ArbreQ = NULL; + noeud *ArbreR = NULL; + noeud *ArbreS = NULL; + noeud *ArbreT = NULL; + noeud *ArbreU = NULL; + noeud *ArbreV = NULL; + noeud *ArbreW = NULL; + noeud *ArbreX = NULL; + noeud *ArbreY = NULL; + noeud *ArbreZ = NULL; + + + FILE *dico=fopen("dico/dico.txt","r"); + + FILE *fichierA=fopen("dico/A.txt","r"); + FILE *fichierB=fopen("dico/B.txt","r"); + FILE *fichierC=fopen("dico/C.txt","r"); + FILE *fichierD=fopen("dico/D.txt","r"); + FILE *fichierE=fopen("dico/E.txt","r"); + FILE *fichierF=fopen("dico/F.txt","r"); + FILE *fichierG=fopen("dico/G.txt","r"); + FILE *fichierH=fopen("dico/H.txt","r"); + FILE *fichierI=fopen("dico/I.txt","r"); + FILE *fichierJ=fopen("dico/J.txt","r"); + FILE *fichierK=fopen("dico/K.txt","r"); + FILE *fichierL=fopen("dico/L.txt","r"); + FILE *fichierM=fopen("dico/M.txt","r"); + FILE *fichierN=fopen("dico/N.txt","r"); + FILE *fichierO=fopen("dico/O.txt","r"); + FILE *fichierP=fopen("dico/P.txt","r"); + FILE *fichierQ=fopen("dico/Q.txt","r"); + FILE *fichierR=fopen("dico/R.txt","r"); + FILE *fichierS=fopen("dico/S.txt","r"); + FILE *fichierT=fopen("dico/T.txt","r"); + FILE *fichierU=fopen("dico/U.txt","r"); + FILE *fichierV=fopen("dico/V.txt","r"); + FILE *fichierW=fopen("dico/W.txt","r"); + FILE *fichierX=fopen("dico/X.txt","r"); + FILE *fichierY=fopen("dico/Y.txt","r"); + FILE *fichierZ=fopen("dico/Z.txt","r"); + + + dicos(dico); + remplissage(&ArbreA,fichierA); + printf("apres remplissage\n"); + + +/* + + lecture(&ArbreA,fichierA); + lecture(&ArbreB,fichierB); + lecture(&ArbreC,fichierC); + lecture(&ArbreD,fichierD); + lecture(&ArbreE,fichierE); + lecture(&ArbreF,fichierF); + lecture(&ArbreG,fichierG); + lecture(&ArbreH,fichierH); + lecture(&ArbreI,fichierI); + lecture(&ArbreJ,fichierJ); + lecture(&ArbreK,fichierK); + lecture(&ArbreL,fichierL); + lecture(&ArbreM,fichierM); + lecture(&ArbreN,fichierN); + lecture(&ArbreO,fichierO); + lecture(&ArbreP,fichierP); + lecture(&ArbreQ,fichierQ); + lecture(&ArbreR,fichierR); + lecture(&ArbreS,fichierS); + lecture(&ArbreT,fichierT); + lecture(&ArbreU,fichierU); + lecture(&ArbreV,fichierV); + lecture(&ArbreW,fichierW); + lecture(&ArbreX,fichierX); + lecture(&ArbreY,fichierY); + lecture(&ArbreZ,fichierZ); +*/ + + + + fclose(dico); + + fclose(fichierA); + fclose(fichierB); + fclose(fichierC); + fclose(fichierD); + fclose(fichierE); + fclose(fichierF); + fclose(fichierG); + fclose(fichierH); + fclose(fichierI); + fclose(fichierJ); + fclose(fichierK); + fclose(fichierL); + fclose(fichierM); + fclose(fichierN); + fclose(fichierO); + fclose(fichierP); + fclose(fichierQ); + fclose(fichierR); + fclose(fichierS); + fclose(fichierT); + fclose(fichierU); + fclose(fichierV); + fclose(fichierW); + fclose(fichierX); + fclose(fichierY); + fclose(fichierZ); + + printf("apres fclose\n"); +/* + FILE *texte=fopen("texte/texte.txt","r"); + textes(texte); + fclose(texte); + + FILE *corrige = fopen("fautes.txt","w"); + fclose(corrige); */ + printf("Ici\n"); + printf("il existe "); + printf(": %d en valeur",ArbreA->valeur); + printf("apres\n"); +// int i,n=strlen(ch) existe(&(*ArbreA->e),'e') +// int tab[n]; +// ascii(tab,ch); +// for(i=0;i