From: Jérôme Benoit Date: Thu, 30 Mar 2017 12:59:10 +0000 (+0200) Subject: TP6: Add word printing to arbre-n-aire.c X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7a4d5d575a2083a3d74b8206391fd1b16c37763c;hp=dfa8da5e6ccb128db8daa5ea21bada4ddac53b91;p=Algorithmic_C.git TP6: Add word printing to arbre-n-aire.c Signed-off-by: Jérôme Benoit --- diff --git a/TP6/arbres/arbre-n-aire/arbre_n_aire.c b/TP6/arbres/arbre-n-aire/arbre_n_aire.c index c10c6bf..63981b5 100644 --- a/TP6/arbres/arbre-n-aire/arbre_n_aire.c +++ b/TP6/arbres/arbre-n-aire/arbre_n_aire.c @@ -84,7 +84,16 @@ void affiche (NOEUD * p, char *mot, int i) { /* i est l'indice de la lettre courante dans le mot */ - /* TODO */ + if (p != NULL) + { + mot[i] = p->lettre; + affiche (p->fils, mot, i + 1); + if (mot[i] == '\0') + { + printf ("%s\n", mot); + } + affiche (p->frere, mot, i); + } } /* Visualisation de l'arbre n-aire *******************************************/ @@ -167,8 +176,12 @@ main (int argc, char *argv[]) gets (mot); printf ("\ninsertion de %s\n", mot); arbre = insere (arbre, mot, 0); + printf ("\naffichage mots:\n"); + affiche (arbre, mot, 0); printf ("\naffichage arbre :\n"); affiche_arbre (arbre, 0); + if (recherche (arbre, "toto", 0)) + printf ("mot present\n"); /* TODO */ }