Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct e{
- int num;
- struct e *fg, *fd;
- }Noeud;
- typedef Noeud * Arbre;
- void init(Arbre *P){
- (*P)->fg=NULL;
- (*P)->fd=NULL;
- }
- void affich_Noeud (Arbre P){
- if(P!=NULL){
- printf("%d\n", P->num);
- affich_Noeud (P->fg);
- affich_Noeud (P->fd);
- }
- }
- Arbre ajout ( Arbre P, int x){
- if ( P==NULL){
- Arbre nouv;
- nouv=(Arbre)malloc(sizeof(Noeud));
- init (&nouv);
- nouv->num=x;
- return nouv;
- }
- else{
- if(P->num =< x){
- if(P->fg!=NULL)
- return ajout(P->fg, x);
- else{
- Arbre nouv;
- nouv=(Arbre)malloc(sizeof(Noeud));
- init (&nouv);
- nouv->num=x;
- P->fg=nouv;
- return P;
- }
- }
- else{
- if(P->fd !=NULL)
- return ajout(P->fd, x);
- else{
- Arbre nouv;
- nouv=(Arbre)malloc(sizeof(Noeud));
- init (&nouv);
- nouv->num=x;
- P->fd=nouv;
- return P;
- }
- }
- }
- }
- int main(int argc, char *argv[])
- {
- Arbre P =NULL;
- int i;
- }
Add Comment
Please, Sign In to add comment