Skip to content

Instantly share code, notes, and snippets.

@YounesCheikh
Created September 23, 2013 21:29
Show Gist options
  • Save YounesCheikh/6677219 to your computer and use it in GitHub Desktop.
Save YounesCheikh/6677219 to your computer and use it in GitHub Desktop.
Now you can test your functions
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