Created
September 23, 2013 21:29
-
-
Save YounesCheikh/6677219 to your computer and use it in GitHub Desktop.
Now you can test your functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct noeud { | |
int info; | |
struct noeud *fg, *fm, *fd; | |
} NOEUD; | |
typedef NOEUD ARBRE_TERNAIRE; | |
int taille( NOEUD *arbre) { | |
if( arbre == NULL) | |
return 0; | |
else return 1 + taille(arbre->fd) + taille(arbre->fm) + taille(arbre->fg); | |
} | |
int min4(int a, int b , int c, int d) { | |
int mini = a; | |
if( mini > b && b != -1) mini = b; | |
if( mini > c && c != -1) mini = c; | |
if( mini > d && d != -1) mini = d; | |
return mini; | |
} | |
int min( NOEUD *arbre) { | |
if( arbre == NULL) { | |
return -1; | |
} | |
else { | |
int minM = min(arbre->fm); | |
int minG = min(arbre->fg); | |
int minD = min(arbre->fd); | |
return min4(arbre->info, minM, minG, minD); | |
} | |
} | |
bool SontImages( NOEUD *arbre1, NOEUD *arbre2) { | |
if ( arbre1 == NULL && arbre2 == NULL) return true; | |
else if ( arbre1 == NULL && arbre2 != NULL) return false; | |
else if ( arbre1 != NULL && arbre2 == NULL ) return false; | |
else { | |
return arbre1->info == arbre2->info && SontImages(arbre1->fd, arbre2->fg) && SontImages(arbre1->fm, arbre2->fm) && SontImages(arbre1->fg, arbre2->fd); | |
} | |
} | |
void Image( NOEUD * arbre, NOEUD *image ) { | |
image->info = arbre->info; | |
image->fm = arbre->fm; | |
Image(arbre->fd, image->fg); | |
Image(arbre->fg, image->fd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment