Yûki - Add DEBUG State
This commit is contained in:
parent
b2e8b8f388
commit
35865485a0
3 changed files with 23 additions and 5 deletions
|
|
@ -3,7 +3,9 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "arbre_binaire.h"
|
#include "arbre_binaire.h"
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define DEBUG 1
|
||||||
|
#endif
|
||||||
arbre creer_arbre_vide (void)
|
arbre creer_arbre_vide (void)
|
||||||
{
|
{
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
@ -70,8 +72,23 @@ void free_arbre(arbre a)
|
||||||
}
|
}
|
||||||
|
|
||||||
void arbre_rechercher(arbre a, Elt c, char s[], int s_len, int found[]){
|
void arbre_rechercher(arbre a, Elt c, char s[], int s_len, int found[]){
|
||||||
|
/*
|
||||||
|
De ce que j'ai testé, ça marche de temps en temps même en ne changeant pas le caractère recherché, je pense qu'il y a un problème avec VSCode encore une fois LOL (Yûki)
|
||||||
|
*/
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("\nDEBUG ARBRE RECHERCHER : \n");
|
||||||
|
printf(" est_arbre_vide(a) : %d\n",est_arbre_vide(a));
|
||||||
|
printf(" est_feuille(a) : %d\n",est_feuille(a));
|
||||||
|
printf(" racine(a) : %c\n",racine(a));
|
||||||
|
printf(" c : %c\n",c);
|
||||||
|
printf(" est_arbre_vide(fils_gauche(a)) : %d\n",est_arbre_vide(fils_gauche(a)));
|
||||||
|
printf(" est_arbre_vide(fils_droit(a)) : %d\n",est_arbre_vide(fils_droit(a)));
|
||||||
|
printf(" S : %s\n",s);
|
||||||
|
printf("--FIN DEBUG ARBRE RECHERCHER--\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!est_arbre_vide(a)){
|
if(!est_arbre_vide(a)){
|
||||||
if(est_feuille(a)&&racine(a)==c){
|
if((a->fils_gauche==NULL&&a->fils_droit==NULL)&&racine(a)==c){
|
||||||
found[0]=1;
|
found[0]=1;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
@ -83,5 +100,6 @@ void arbre_rechercher(arbre a, Elt c, char s[], int s_len, int found[]){
|
||||||
s[s_len]='1';
|
s[s_len]='1';
|
||||||
arbre_rechercher(fils_droit(a),c,s,s_len+1,found);
|
arbre_rechercher(fils_droit(a),c,s,s_len+1,found);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
Ceci est un test.
|
mon code C est le meilleure : int myfunction(arbre ahah){printf("coucou");pointeur->quipointe;}
|
||||||
|
|
@ -41,9 +41,9 @@ int main(int argc, char **argv){
|
||||||
|
|
||||||
// Récupération du code de chaque charactere
|
// Récupération du code de chaque charactere
|
||||||
printf("Code : \n");
|
printf("Code : \n");
|
||||||
char s[8]="2";
|
char s[80]="";
|
||||||
int f[1]={0};
|
int f[1]={0};
|
||||||
char search=' ';
|
char search='-';
|
||||||
arbre_rechercher(huff,search,s,0,f);
|
arbre_rechercher(huff,search,s,0,f);
|
||||||
if(f[0]==1){
|
if(f[0]==1){
|
||||||
printf("\nTrouve : %s\n",s);
|
printf("\nTrouve : %s\n",s);
|
||||||
|
|
|
||||||
Reference in a new issue