+ الرد على الموضوع
النتائج 1 إلى 6 من 6

الموضوع: tp en langage c les arbres

  1. #1

    • Offline
    • جامع علم متميز
    • nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز

    تاريخ التسجيل
    Jun 2010
    مكان الإقامة
    أرض الجزائر الحبيبة
    المشاركات
    128
    المفات المحملة
    2
    الملفات المرفوعة
    0
    معدل تقييم المستوى
    77

    flwr tp en langage c les arbres

    السلام عليكم و رحمة الله تعالى وبركاته
    هذا البرنامج يحتوي على 2 projets
    les arbres binaires de recherche et l implémentation des tas par tableau
    sachant que:
    les tas sont des arbres binaire tq la valeur de chaque noeud est inférieur(superieur) a les valeurs de ses fils

    donc la valeur du racine sera le min(max). cet arbre appelé MIN-HEAP (MAX-HEAP ) ..voici le programme
    إستعميلوا borland c++ 4.52

    ملاحظة
    ملاحظة
    عند نسخ البرنامج لا تنسخوا ثلاث الأحرف الأولىinc







    inc #include <stdio.h>
    #include <stdlib.h>
    //***************************la structure de l'arbre****************************

    typedef struct arbre_e
    {
    int val;
    struct arbre_e*fg;
    struct arbre_e*fd;
    }*arbree;
    //***************************la structure du tableau****************************
    typedef struct tableau_ee
    {
    int*tab;
    int taille;
    }tableaue;
    //******************************creation d'un tableau vide************************
    /*cette fonction ceere un tableau vide
    les entres:la taille de tableau
    les sortie:tableau vide
    */
    tableaue creer_tableaue_vide(int t)
    {
    tableaue v;
    v.taille=t;
    v.tab=new int [t];
    return v;
    }
    //******************************creation d'un arbre vide************************
    /*cette fonction ceere un arbre vide
    les sortie:arbre vide
    */
    arbree cree_arbree_vide()
    {return NULL;}
    //********************************création d'une noeud**************************
    /*cette fonction ceere un arbre de un seule noeud
    les entres:la valeur choisie
    les sortie:un arbre de un seule noeud
    */
    arbree creer_noeude(int v)
    {
    arbree a;
    a=(arbree)malloc(sizeof(struct arbre_e));
    a->val=v;
    a->fd=NULL;
    a->fg=NULL;
    return a;
    }
    //************************************************** ****************************
    //********************************l'affichage de l'arbre************************
    //*********************************parcoure préfixe*****************************
    /*cette fonction fait le parcoure préfixé
    les entres:l'arbre de recherche
    */
    void affiche_prefixe(arbree a)
    {
    if (a!=NULL)
    {
    printf(" ");
    printf("%d",a->val);
    affiche_prefixe(a->fg);
    affiche_prefixe(a->fd);
    }
    }
    //********************************le trie croissant*******************************
    /*cette fonction fait le trier croissant
    les entres:l'arbre de recherche
    */
    void trier1(arbree a)
    {
    if (a!=NULL)
    {
    trier1(a->fg);
    printf(" ");
    printf("%d",a->val);
    trier1(a->fd);
    }
    }
    //*****************************le trie decroissant******************************
    /*cette fonction fait le trier décroissant
    les entres:l'arbre de recherche
    */
    void trier2(arbree a)
    {
    if (a!=NULL)
    {
    trier2(a->fd);
    printf(" ");
    printf("%d",a->val);
    trier2(a->fg);
    }
    }
    //********************************parcoure infixé*******************************
    /*cette fonction fait le parcoure infixé
    les entres:l'arbre de recherche
    */
    void affiche_infixe(arbree a)
    {
    if (a!=NULL)
    {
    affiche_infixe(a->fg);
    printf(" ");
    printf("%d",a->val);
    affiche_infixe(a->fd);
    }
    }
    //******************************parcour sufixe**********************************
    /*cette fonction fait le parcoure sufixé
    les entres:l'arbre de recherche
    */
    void affiche_sufixe(arbree a)
    {
    if (a!=NULL)
    {
    affiche_sufixe(a->fg);
    affiche_sufixe(a->fd);
    printf(" ");
    printf("%d",a->val);
    }
    }
    //*****************************nombre de noeud d'arbre**************************
    /*cette fonction fait le calcul des noeud de l'arbre
    les entres:l'arbre de recherche
    les sortie: un nombre entier (nombre des noeud)
    */
    int nb_noeuds(arbree &a)
    {
    if(a==NULL)return 0;
    else
    return(1+ nb_noeuds(a->fg)+ nb_noeuds(a->fd));
    }
    //**********************creation de l'arbre de recherche************************
    /*cette fonction fait la creation de l'arbre de recherche
    les entres:un suite des valeurs
    */
    void creer_arbree(arbree &a,int v)
    {
    if(a!=NULL)
    {
    if (a->val==v)
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("la valeur est repétée dans ce type d'arbre on doit pas redoubler lez valeurs");
    printf("\n--------------------------------------------------------------------------------");
    }
    else
    {
    if(a->val>v)
    {creer_arbree(a->fg,v);}
    else
    creer_arbree(a->fd,v);
    }
    }
    else
    {
    a=(arbree)malloc(sizeof(struct arbre_e));
    a->val=v;
    a->fd=NULL;
    a->fg=NULL;
    }
    }
    //*******************************creer un tableau*******************************
    /*cette fonction ceere un tableau a ppartir d'un arbre de recherche
    les entres:arbre de recherche
    */
    void creer_tableaue(int t,tableaue &p,arbree &a)
    {
    int i;
    int val;
    p=creer_tableaue_vide(t);
    for(i=0;i<=(t-1);i++)
    {
    printf("entrer votre valeur de l'indice: ");
    printf("%d",i);
    printf("\nvaleur=");
    scanf("%d",&val);
    p.tab[i]=val;
    creer_arbree(a,p.tab[i]);
    }

    }
    //****************l'insertion dans une arbre binaire de recherche***************
    /*cette fonction insert un valeur dans l'arbre
    les entres:l'arbre de recherche
    */
    void inserer(arbree &a,int val)
    {if(a==NULL)
    {a=(arbree)malloc(sizeof(arbre_e));
    a->val=val;
    a->fg=NULL;
    a->fd=NULL;
    }
    else
    {
    if(val>a->val){inserer(a->fd,val);}
    if(val<a->val){inserer(a->fg,val);}
    }
    }
    //*********************************la supression********************************
    /*cette fonction sepprime un valrur de l'arbre
    les entres:l'arbre de recherche
    */
    /*arbree suprimer(arbree &a,int c)
    {
    if(a!=NULL)
    {
    if(c==a->val)
    return(suprimer_noeud(a);
    else
    {
    if(c>a->val)
    a->fd=suprimer(a->fd,c);
    else
    a->fg=suprimer(a->fg,c);
    }}
    return a;
    }
    //*******************************suprimer noeud*********************************
    arbree suprimer_noeud(arbre a)
    {

    */
    //********************************la hauteur************************************
    /*cette fonction calcul l'hauteur de l'arbre
    les entres:l'arbre de recherche
    les sortie:un nombre entier (l'hauteur)
    */
    int hauteur(arbree &a)
    {
    if(a==NULL)
    return -1;
    else
    {
    if((a->fg==NULL)&&(a->fd==NULL))
    return 0;
    else
    return (1+max(hauteur(a->fg),hauteur(a->fd)));
    }
    }
    //================================================== ============================
    //==================================les tas=====================================
    //================================================== ============================
    //***************************la structure du tableau****************************
    typedef struct tableau_
    {
    int*tab;
    int taille;
    }tableau;
    //******************************creer un tableau vide***************************
    /*cette fonction ceere un tableau vide
    les entres:la taille de tableau
    les sortie:un tablaeu vide
    */
    tableau creer_tableau_vide(int t)
    {
    tableau v;
    v.taille=t;
    v.tab=new int [t];
    return v;
    }
    //***************************la structure de l'arbre****************************
    typedef struct arbre_
    {
    int*tab;
    int tmax;
    int taille;
    }arbre;
    //******************************creation d'un tas vide************************
    /*cette fonction créere un tas vide
    les entres:le nombre des neouds de l'arbre
    les sortie:l'arbre vide
    */
    arbre creer_tas_vide(int t)
    {
    arbre a;
    a.tmax=(t+11);
    a.tab=new int [t];
    return a;
    }
    //*******************************creer un tableau*******************************
    /*cette fonction remplie le tableau
    les entres:tableau vide et tableau vide
    les sortie:le tableau remplie
    */
    tableau creer_tableau(int t,tableau &p)
    {
    int i,n;
    p=creer_tableau_vide(t);
    for(i=0;i<=(t-1);i++)
    {
    printf("entrer votre valeur de l'indice: ");
    printf("%d",i);
    printf("\nvaleur=");
    scanf("%d",&n);
    p.tab[i]=n;

    }
    return p;
    }
    //***************************l'insertion dans un tas(min)****************************
    /*cette fonction insere un valeur
    les entres:arbre vide
    les sortie:un nombre entier (l'hauteur)
    */
    void inserer(arbre &a,int val)
    {
    int i,x;
    a.taille++;
    a.tab[a.taille]=val;
    i=a.taille;
    while((i>1)&&(a.tab[i/2]>=val))
    {
    x=a.tab[i/2];
    a.tab[i/2]=a.tab[i];
    a.tab[i]=x;
    i=i/2;
    }
    a.tab[i]=val;
    }
    //***************************l'insertion dans un tas(max)****************************
    /*cette fonction inser un
    les entres:l'arbre de recherche et un valeur
    */
    void inserer_max(arbre &a,int val)
    {
    int i,x;
    a.taille++;
    a.tab[a.taille]=val;
    i=a.taille;
    while((i>1)&&(a.tab[i/2]<=val))
    {
    x=a.tab[i/2];
    a.tab[i/2]=a.tab[i];
    a.tab[i]=x;
    i=i/2;
    }
    a.tab[i]=val;
    }
    //*******************************creation de tas(min)******************************
    /*cette fonction creer un tas min
    les entres:le tableux remplie et l'arbea vide et un entier
    */
    void creer_tas(arbre &a,tableau p,int t)
    {
    int i;
    a=creer_tas_vide(t);
    a.tab[1]=p.tab[0];
    a.taille=1;
    for(i=1;i<(p.taille);i++)
    {
    inserer(a,p.tab[i]);
    }
    }
    //*****************************creation de tas (max)****************************
    /*cette fonction creer un tas max
    les entres:le tableux remplie et l'arbea vide et un entier
    */
    void creer_tas_max(arbre &a,tableau p,int t)
    {
    int i;
    a=creer_tas_vide(t);
    a.tab[1]=p.tab[0];
    a.taille=1;
    for(i=1;i<(p.taille);i++)
    {
    inserer_max(a,p.tab[i]);
    }
    }
    //*********************************L'AFFICHAGE DU TAS***************************
    /*cette fonction affiche un tas
    les entres:l'arbre remplie
    */

    void affiche(arbre a)
    {
    int i,j,t;t=0;
    for (i=1;i<=(a.taille);i=(2*i))
    {
    printf("le niveau'");
    printf("%d",t);
    printf("':");

    for (j=i;j<(2*i);j++)
    {
    if ((j>0)&&(j<=a.taille))
    printf(" %d ",a.tab[j]);
    }
    printf( "\n\n");
    t++;
    }
    }
    //****************************nombre de noeud de tas****************************
    /*cette fonction fait le calcul des noeud de l'arbre
    les entres:l'ats
    les sortie: un nombre entier (nombre des noeud)
    */
    int nbr_noeud(arbre a)
    {
    printf ("le nombre de noeud de votre tas est: ");
    return(a.taille);
    }
    //***************************retourner les deux fils****************************
    /*cette fonction returne les deux fils d'un noeud
    les entres:l'ats rempil et la position de noeud
    */
    void retourne(arbre a,int pos)
    {
    printf("\ntappez la position de votre noeud \n");
    printf("la position=\n");
    scanf("%d",&pos);
    if(pos>0&&pos<=a.taille)
    {
    printf("les fils de noeud ");
    printf("%d",a.tab[pos]);
    printf(" sont:\n");
    if((2*pos)>0&&(2*pos)<=a.taille)
    {printf("\nla valeur de fils gauche= ");printf("%d",a.tab[2*pos]);}
    else
    {
    printf("\ncette noeud n a pas un fils gauche");}
    if((2*pos+1)>0&&(2*pos+1)<=a.taille)
    {printf("\nla valeur de fils drois= ");printf("%d",a.tab[2*pos+1]);}
    else
    {
    printf("\ncette noeud n a pas un fils drois");
    }
    }
    else
    printf("\nla cette position n existe pas");
    }
    //****************************retourner le pere d un fils***********************
    /*cette fonction returne le pere d'un fils d'un noeud
    les entres:l'ats rempil et la position de fils
    */
    void retourne_pere(arbre a,int pos)
    {
    printf("\ntappez la position de votre fils \n");
    printf("la position=\n");
    scanf("%d",&pos);
    if(pos>1&&pos<=a.taille)
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("\nle pere de ce fils (");
    printf("%d",a.tab[pos]);printf(")");
    printf(" est: ");
    printf("%d",a.tab[pos/2]);
    printf("\n--------------------------------------------------------------------------------");
    }
    else
    {
    if(pos==1)
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("\nce noeud n a pas un pere: c est la racine");
    printf("\n--------------------------------------------------------------------------------");
    }
    else
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("\ncette position n existe pas");
    printf("\n--------------------------------------------------------------------------------");
    }
    }}
    //*************************tester le noeud s il est une feuille*****************
    /*cette fonction teste si le noeud est feuille
    les entres:l'ats rempil et la position de noeud
    */
    void teste_feuille(arbre a,int pos)
    {
    printf("\ntappez la position de votre fils \n");
    printf("la position=\n");
    scanf("%d",&pos);
    if(pos>0&&pos<=a.taille)
    {
    if((2*pos)>0&&(2*pos)<=a.taille)
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("\nce noeud (");
    printf("%d",a.tab[pos]);
    printf(") n est pas une feuille");
    printf("\n--------------------------------------------------------------------------------");
    }
    else
    {
    if((2*pos+1)>0&&(2*pos+1)<=a.taille)
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("\nce noeud (");
    printf("%d",a.tab[pos]);
    printf(") n est pas une feuille");
    printf("\n--------------------------------------------------------------------------------");}
    else
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("\nce noeud (");
    printf("%d",a.tab[pos]);
    printf(") est une feuille");
    printf("\n--------------------------------------------------------------------------------");}
    }
    }
    }
    /*_________________________________________________ _____________________________
    les files
    __________________________________________________ _____________________________*/
    //*********************************la structure de file*************************
    typedef struct file
    {
    arbree *tab;
    int taille,fin,debut;
    }file;
    //*****************************creer une file vide******************************
    /*cette fonction creer une file vide
    les entres:la taille de la file
    */
    void creer_file_vide(int t)
    {
    file f;
    f.taille=t;
    f.debut=-1;
    f.fin=-1;
    f.tab=new arbree[t];
    }
    //****************************tester si la file est vide************************
    /*cette fonction teste si la file est vide
    les entres:la file
    */
    int test_file_vide(file f)
    {
    return (f.debut==-1);
    }
    //**************************tester si la file est pleinne***********************
    /*cette fonction teste si la file est plienne
    les entres:la file
    */
    int test_file_pleinne(file f)
    {
    return (f.fin==f.taille);
    }
    //********************************l enfilement*********************************
    /*cette fonction enfile un valeur
    les entres:la file et larbre
    */
    void enfiler(file &f,arbree &c)
    {
    if (!test_file_pleinne(f))
    {
    if(f.fin==-1)
    {
    f.debut=0;
    f.fin=0;
    f.tab[f.debut]=c;
    }
    else
    {
    f.fin++;
    f.tab[f.fin]=c;
    }
    }
    else
    printf("impossible d enfiler(la file est pleinne)\n");
    }
    //********************************le defilement*********************************
    /*cette fonction dépile un valeur
    les entres:la file et larbre
    */
    arbree defiler(file &f)
    { arbree c;
    if (!test_file_vide(f))
    {
    if(f.fin==f.debut)
    {
    f.fin=-1;
    f.debut=-1;
    }
    else
    {
    int i;
    c=f.tab[f.debut];
    for(i=f.debut;i<f.fin;i++)
    f.tab[i]=f.tab[i+1];
    }

    f.fin--;
    f.debut=0;
    }
    else
    printf("imposible de defiler(la file est vide)\n");
    return c;
    }
    //***************la creation de tas a partir d un vecteur ordoner***************
    void creer_tas_vect(arbre a,file &f,arbree &c)
    {
    creer_file_vide(a.taille);
    c=creer_noeude(a.tab[1]);
    enfiler(f,c);
    int i=2;
    while((i<a.taille)&&(!test_file_vide(f)))
    {
    c=defiler(f);
    c->fg=creer_noeude(a.tab[i]);
    enfiler(f,c->fg);
    c->fd=creer_noeude(a.tab[i+1]);
    enfiler(f,c->fd);
    i=2*i;
    }
    }
    //************************la supression dans le minheap*************************
    void suprimer_min(arbre &a)
    {
    int pos;
    printf("tappez la position de valeur a suprimer\n");
    scanf("%d",&pos);
    int i,j;
    int v,t;
    t=a.tab[1];
    a.tab[pos]=a.tab[a.taille];
    a.taille--;
    i=pos;
    v=a.tab[pos];
    while((2*i)<=a.taille)
    {
    j=(2*i);
    if((j+1)<=a.taille)
    if(a.tab[j+1]<a.tab[j])
    j++;
    if(v<=a.tab[j])
    break;
    a.tab[i]=a.tab[j];
    i=j;
    }
    a.tab[i]=v;
    }
    //*****************************la supression dans le maxheap********************
    void suprimer_max(arbre &a)
    {
    int pos;
    printf("tappez la position de valeur a suprimer\n");
    scanf("%d",&pos);
    int i,j;
    int v,t;
    t=a.tab[1];
    a.tab[pos]=a.tab[a.taille];
    a.taille--;
    i=pos;
    v=a.tab[pos];
    while((2*i)<=a.taille)
    {
    j=(2*i);
    if((j+1)<=a.taille)
    if(a.tab[j+1]>a.tab[j])
    j++;
    if(v>=a.tab[j])
    break;
    a.tab[i]=a.tab[j];
    i=j;
    }
    a.tab[i]=v;
    }
    //***********************tester si le tableau est un tas***************************
    int test_tas_min(arbre a)
    {
    int i;
    i=a.taille;
    while((i>1)&&(a.tab[i]>=a.tab[i/2]))
    {
    i--;
    }
    {
    if(i>1)
    return 0;
    else
    if(i<=1)
    return 1;
    } }

    //***********************tester si l arbre est un tas***************************
    int test_tas_max(arbre a)
    {
    int i;
    i=a.taille;
    while((i>1)&&(a.tab[i]<=a.tab[i/2]))
    {
    i--;
    }
    {
    if(i>1)
    return 0;
    else
    if(i<=1)
    return 1;
    } }
    //***********************tester si l arbre est un tas***************************
    int test_tas(tableau a)
    {
    int i;
    i=a.taille-1;
    while((i>=0)&&(a.tab[i]<=a.tab[i/2]))
    {
    i--;
    }
    {
    if((a.tab[i]>a.tab[i/2]))
    return 0;
    else
    if(i<0)
    return 1;
    } }
    //****************************retourner la plus grand valeur********************
    int valeur_min_max(arbre a)
    {
    return a.tab[1];
    }

    /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    LE PROGRAMME PRINCIPALE
    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
    void main()
    {
    char r,c;
    r='y';
    do
    {
    printf("-------------------------------------------------------------------------------");
    printf("\nvoici les deux projet siuvants:");
    printf("\n -1<=>le trie par arbre binaire de recherche");
    printf("\n -2<=>les tas");
    printf("\n-------------------------------------------------------------------------------");
    printf("\nchoisissez une fonction SVP\n");
    printf("--------------------------*****REMARQUE*****------------------------------------\n");
    printf("pour selectioner le trie appuez sur 1\n");
    printf("pour selectioner les tas appuez sur 2\n");
    printf("votre choix est:\n");
    scanf("%s",&c);
    printf("-------------------------------------------------------------------------------");
    switch(c)
    {
    case'1':
    printf("\n--------------------------------------------------------------------------------");
    arbree a;
    int v;
    int t;
    tableaue p;
    puts("tappez la valeur du racine de l'arbre\n");
    puts("la valeur=\n");
    scanf("%d",&v);
    a= creer_noeude(v);
    if(a!=NULL)
    {
    printf("\n--------------------------------------------------------------------------------");
    printf("cette fonction creée un arbre binair tq tous les fils drois sont superieur à la racine et tous les fils gauches sont inferieur à la racine\n");
    printf("--------------------------------------------------------------------------------");
    printf("tappez le nombre de noeuds de votre arbre");
    printf("\nle nombre=\n");
    scanf("%d",&t);
    creer_tableaue(t,p,a);
    char rep,choix;
    rep='y';
    do
    {
    printf("-------------------------------------------------------------------------------");
    printf("\nvoici les fonctions des parcoures et autres fonctions:");
    printf("\n -1<=>parcoure préfixé");
    printf("\n -2<=>parcoure infixé");
    printf("\n -3<=>parcoure suffixé");
    printf("\n -4<=>l'insertion");
    printf("\n -5<=>supression");
    printf("\n -6<=>la hauteur");
    printf("\n -7<=>nombre de noeud de l'arbre");
    printf("\n -8<=>le tri croissant");
    printf("\n -9<=> le tri decroissant");
    printf("\n -0<=>quiter le programme");
    printf("\n-------------------------------------------------------------------------------");
    printf("\nchoisissez une fonction SVP\n");
    printf("votre choix est:\n");
    scanf("%s",&choix);
    printf("-------------------------------------------------------------------------------");
    switch(choix)
    {
    case'1':
    printf("\n le parcoure prefixe:\n");
    affiche_prefixe(a);
    printf("\n--------------------------------------------------------------------------------");break;
    case'2':
    printf("\n le parcoure infixé:\n");
    affiche_infixe(a);
    printf("\n--------------------------------------------------------------------------------");break;
    case'3':
    printf("\n le parcoure sufixé:\n");
    affiche_sufixe(a);
    printf("\n--------------------------------------------------------------------------------");break;
    case'8':
    printf("\nle trie coissant de votre tableau est:\n");
    trier1(a);
    printf("\n--------------------------------------------------------------------------------");break;
    case'9':
    printf("\nle trie decoissant de votre tableau est:\n");
    trier2(a);
    printf("\n--------------------------------------------------------------------------------");break;
    case'4':
    printf("\ntappez la valeur a inseree:\n");
    int val;
    printf("\nla valeur=\n");
    scanf("%d",&val);
    inserer(a,val);
    printf("\n--------------------------------------------------------------------------------");break;
    case'6':
    printf("\nla hauteur de votre arbre est: ");
    int v;
    v=hauteur(a);
    printf("%d",v);
    printf("\n--------------------------------------------------------------------------------");break;
    case'7':
    printf("\nle nombre de noeud est: ");
    int o;
    o=nb_noeuds(a);
    printf("%d",o);
    printf("\n--------------------------------------------------------------------------------");break;

    case '0' :

    printf("\npour quiter ce projet appuez sur n");
    printf("\n--------------------------------------------------------------------------------");break;

    }

    printf("\nvoulez vous choisissez un autre choix?(YES=y/NO=n)\n");
    scanf("%s",&rep);
    }while(rep=='y');

    }
    printf("\n--------------------------------------------------------------------------------");break;












































    case'2':
    int o,vall,n;
    tableau g;
    arbre aa;
    int pos,s,b;
    char rep2,choix;
    printf("\ntappez taille de votre tableau");
    printf("\nla taille=\n");
    scanf("%d",&o);
    g=creer_tableau_vide(o);
    g=creer_tableau(o,g);

    rep2='y';
    do
    {
    printf("\n-------------------------------------------------------------------------------");
    printf("\nvoici les fonctions siuvantes:");
    printf("\n -1<=>tester si l arbre est un tas");
    printf("\n -2<=>creer un MAX-HEAP");
    printf("\n -3<=>creer un MIN-HEAP");
    printf("\n -0<=>quiter ces fonctions");
    printf("\n-------------------------------------------------------------------------------");
    printf("\nchoisissez une fonction SVP\n");
    printf("votre choix est:\n");
    scanf("%s",&choix);
    printf("-------------------------------------------------------------------------------");
    switch(choix)
    {
    case'1':
    int l;
    l=test_tas(g);
    if(l==0)
    printf("\ncet arbre n est pas un tas");
    if(l==1)
    printf("\ncet arbre est un tas");
    printf("\n--------------------------------------------------------------------------------");break;

    case'3':
    char preferencemin,reponcen;
    aa=creer_tas_vide(o);
    creer_tas(aa,g,o);
    reponcen='o';
    do
    {
    printf("-------------------------------------------------------------------------------");
    printf("\nvoici les fonctions siuvantes:");
    printf("\n -1<=>tester si l arbre est un tas");
    printf("\n -2<=>Insertion dans un tas");
    printf("\n -3<=>La supression dans un tas");
    printf("\n -4<=>nombre de noeud de tas");
    printf("\n -5<=>tester si noeud est une feuille");
    printf("\n -6<=>retourner le pere d'un fils selon une position");
    printf("\n -7<=>retourner les fils d'un noeud selon une position");
    printf("\n -8<=>le tri croissant");
    printf("\n -9<=> le tri decroissant");
    printf("\n -0<=>l'affichage du tas");
    printf("\n-------------------------------------------------------------------------------");
    printf("\nchoisissez une fonction SVP\n");
    printf("votre choix est:\n");
    scanf("%s",&preferencemin);
    switch(preferencemin)
    {
    case'0':
    int t;
    t=valeur_min_max(aa);
    printf("\nvotre arbre est composé de:\n");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    printf("\nla valeur minimale de votre tas est: ");
    printf("%d",t);
    printf("\n--------------------------------------------------------------------------------");break;
    case'3':
    printf("\n l arbre avant la supression:\n");
    affiche(aa);
    suprimer_min(aa);
    printf("\n--------------------------------------------------------------------------------");
    printf("l arbre apes la supression:\n\n\n");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");break;
    case'1':
    printf("\n--------------------------------------------------------------------------------");
    int l;
    if(l==0)
    printf("\ncet arbre n est pas un tas");
    if(l==1)
    printf("\ncet arbre est un MIN-HEAP");
    printf("\n--------------------------------------------------------------------------------");break;

    case'2':
    printf("tappez la valeur à inserer\n");
    scanf("%d",&vall);
    inserer(aa,vall);
    printf("\n--------------------------------------------------------------------------------");
    printf("\nvotre arbre est composé de:\n");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");break;
    case'4':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    n=nbr_noeud(aa);
    printf("%d",n);
    printf("\n--------------------------------------------------------------------------------");break;
    case'7':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    retourne(aa,pos);
    printf("\n--------------------------------------------------------------------------------");break;
    case'6':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    retourne_pere(aa,s);
    printf("\n--------------------------------------------------------------------------------");break;
    case'5':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    teste_feuille(aa,b);
    printf("\n--------------------------------------------------------------------------------");break;

    }
    printf("\nvoulez vous choisissez un autre choix?(OUI=o/NON=n)\n");
    scanf("%s",&reponcen);
    }while(reponcen=='o');

    printf("\n--------------------------------------------------------------------------------");break;













    case'2':
    char preferencemax,reponce;
    aa=creer_tas_vide(o);
    creer_tas_max(aa,g,o);
    reponce='o';
    do
    {
    printf("-------------------------------------------------------------------------------");
    printf("\nvoici les fonctions siuvantes:");
    printf("\n -1<=>tester si l arbre est un tas");
    printf("\n -2<=>Insertion dans un tas");
    printf("\n -3<=>La supression dans un tas");
    printf("\n -4<=>nombre de noeud de tas");
    printf("\n -5<=>tester si noeud est une feuille");
    printf("\n -6<=>retourner le pere d'un fils selon une position");
    printf("\n -7<=>retourner les fils d'un noeud selon une position");
    printf("\n -8<=>le tri croissant");
    printf("\n -9<=> le tri decroissant");
    printf("\n -0<=>l'affichage du tas");
    printf("\n-------------------------------------------------------------------------------");
    printf("\nchoisissez une fonction SVP\n");
    printf("votre choix est:\n");
    scanf("%s",&preferencemax);
    switch(preferencemax)
    {
    case'0':
    printf("\n--------------------------------------------------------------------------------");
    printf("\nvotre arbre est composé de:\n\n");
    affiche(aa);
    int t;
    printf("\n--------------------------------------------------------------------------------");
    t=valeur_min_max(aa);
    printf("\nla valeur maximale de votre tas est: ");
    printf("%d",t);
    printf("\n--------------------------------------------------------------------------------");break;
    case'3':
    printf("\n l arbre avant la supression:\n");
    affiche(aa);
    suprimer_max(aa);
    printf("\n--------------------------------------------------------------------------------");
    printf("l arbre apes la supression:\n\n\n");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");break;
    case'1':
    int l;
    printf("\n--------------------------------------------------------------------------------");
    l=test_tas_max(aa);
    if(l==0)
    printf("\ncet arbre n est pas un tas");
    if(l==1)
    printf("\ncet arbre est un MAX-HEAP");
    printf("\n--------------------------------------------------------------------------------");break;

    case'2':
    printf("tappez la valeur à inserer\n");
    scanf("%d",&vall);
    inserer_max(aa,vall);
    printf("\n--------------------------------------------------------------------------------");
    printf("\nvotre arbre est composé de:\n");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");break;
    case'4':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    n=nbr_noeud(aa);
    printf("%d",n);
    printf("\n--------------------------------------------------------------------------------");break;
    case'7':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    retourne(aa,pos);
    printf("\n--------------------------------------------------------------------------------");break;
    case'6':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    retourne_pere(aa,s);
    printf("\n--------------------------------------------------------------------------------");break;
    case'5':
    printf("\n--------------------------------------------------------------------------------");
    affiche(aa);
    printf("\n--------------------------------------------------------------------------------");
    teste_feuille(aa,b);
    printf("\n--------------------------------------------------------------------------------");break;

    }
    printf("\nvoulez vous choisissez un autre choix?(OUI=o/NON=n)\n");
    scanf("%s",&reponce);
    }while(reponce=='o');

    printf("\n--------------------------------------------------------------------------------");
    break;
    case '0' :

    printf("\npour quiter ce projet appuez sur n");
    printf("\n--------------------------------------------------------------------------------");break;











    }
    printf("\nvoulez vous choisissez un autre choix(max/min)?(YES=y/NO=n)\n");
    scanf("%s",&rep2);
    }while(rep2=='y');

    printf("\n--------------------------------------------------------------------------------");break;


    case 'Q' :
    printf("\n--------------------------------------------------------------------------------");
    printf("\npour quiter ce projet appuez sur n");
    printf("\n--------------------------------------------------------------------------------");break;

    }


    printf("\nvoulez vous choisissez un autre projet?(YES=y/NO=n)\n");
    scanf("%s",&c);
    }while(c=='y');

    printf("\n--------------------------------------------------------------------------------");
    printf("\n FIN DE projet (LES TAS) ");

    printf("\n préparé par:\n");
    printf(" NOUHA ");
    printf("\n ");
    printf("\n--------------------------------------------------------------------------------");
    printf("\nSVP monsieur tappez notre note et votre observation");
    int note;
    char obser[10];
    printf("\nLA NOTE=");
    scanf("%d",&note);
    printf("\nL OBSERVATION=");
    scanf("%s",&obser);

    printf("\n----------------------------------------------------------------\n");
    printf(" LA NOTE L OBSERVATION\n");
    printf(" %d", note);
    printf(" %s",obser);
    printf("\n----------------------------------------------------------------\n");


    }











    التعديل الأخير تم بواسطة nouha*y*h ; 21-08-2010 الساعة 01:39 PM سبب آخر: إسم الأستاذ كان مذكور أخاف أن يغضب فهو يحمل هذا البرنامج
    توقيع : nouha*y*h

    اللهم إني أسألك حبك و حب من أحبك


    وحب عمل يقربني إلى حبك


    اللهم ما رزقتني مما أحب فاجعله قوة لي فيما تحب


    اللهم ما أخذت مني فيما أحب فاجعله فراغا لي فيما تحب


  2. 3 أعضاء قالوا شكراً لـ nouha*y*h على المشاركة المفيدة:

    91 yahiaoui (18-12-2010), حمزة  (21-08-2010), نصرالدين  (21-08-2010)

  3. #2

    • Offline

    • :: المدير العام ::
    • نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف نصرالدين محترف

    تاريخ التسجيل
    Feb 2007
    مكان الإقامة
    أرض جامع العلوم
    المشاركات
    2,365
    المفات المحملة
    33
    الملفات المرفوعة
    27
    معدل تقييم المستوى
    100

    افتراضي رد: tp en langage c les arbres

    و عليكم السلام و رحمة الله و بركاته
    أشكرك جزيل الشكر على مشاركتنا العمل الموجه.


  4. #3

    • Offline

    • ۞ اللهــــم بلغنــــــا جنتــــــك ۞
    • حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع حمزة محترف مبدع

    تاريخ التسجيل
    Aug 2008
    مكان الإقامة
    أرض الله واسعة
    العمر
    23
    المشاركات
    2,860
    المفات المحملة
    17
    الملفات المرفوعة
    47
    معدل تقييم المستوى
    100

    افتراضي رد: tp en langage c les arbres

    بارك الله فيك

    توقيع : حمزة


    هنا تستطيع مشاهدة : مواضيعي

    .:×،؛، غائب ،؛،×:.


    لا تنسونا من صالح دعائكم ...




  5. #4

    • Offline
    • جامع علم متميز
    • nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز

    تاريخ التسجيل
    Jun 2010
    مكان الإقامة
    أرض الجزائر الحبيبة
    المشاركات
    128
    المفات المحملة
    2
    الملفات المرفوعة
    0
    معدل تقييم المستوى
    77

    افتراضي رد: tp en langage c les arbres

    لا شكر على واجب أخي نصر الدين
    وفبك بركة أخي حمزة
    أرجوأ أن تكون مشاركتي قد نالت إعجابكم.
    سلام.


  6. #5

    • Offline
    • جامع علم متميز
    • emmy يستحق التميز emmy يستحق التميز

    تاريخ التسجيل
    Aug 2010
    المشاركات
    133
    المفات المحملة
    0
    الملفات المرفوعة
    0
    معدل تقييم المستوى
    43

    افتراضي رد: tp en langage c les arbres

    شكرا لك لا تحرمنا من المزيد

    توقيع : emmy

  7. #6

    • Offline
    • جامع علم متميز
    • nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز nouha*y*h يستحق التميز

    تاريخ التسجيل
    Jun 2010
    مكان الإقامة
    أرض الجزائر الحبيبة
    المشاركات
    128
    المفات المحملة
    2
    الملفات المرفوعة
    0
    معدل تقييم المستوى
    77

    افتراضي رد: tp en langage c les arbres

    لا شكر على واجب
    ان احتجت أي شيئ فلا تترددي نحن في الخدمة



 
+ الرد على الموضوع

معلومات الموضوع

الأعضاء الذين يشاهدون هذا الموضوع

الذين يشاهدون الموضوع الآن: 1 (0 من الأعضاء و 1 زائر)

     

المواضيع المتشابهه

  1. exercices sur le langage pascal
    بواسطة HOUSSAM في المنتدى المرحلة التمهيدية (الخوارزميات)
    مشاركات: 10
    آخر مشاركة: 10-11-2010, 06:46 AM
  2. un compilateur d'expression arithmetique vers le langage intermidiaire :postfixé
    بواسطة zahra info في المنتدى السنة الثالثة إعلام آلي 3ème année Informatique
    مشاركات: 29
    آخر مشاركة: 28-10-2010, 08:01 AM
  3. كتاب théorie de langage
    بواسطة حمزة في المنتدى السنة الثانية إعلام آلي 2ème année Informatique
    مشاركات: 16
    آخر مشاركة: 17-04-2010, 11:59 PM

مواقع النشر (المفضلة)

مواقع النشر (المفضلة)

ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك