Advertisement
ProToTN

Untitled

May 16th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "header.h"
  4. #include <string.h>
  5.  
  6.  
  7.  
  8. void saisir(demande *d)
  9. {
  10.     int code;
  11.     char dest[50];
  12.     char date[20];
  13.  
  14.     printf("\nCode: ");
  15.     scanf("%d",&d->code);
  16.     printf("\nDestination: ");
  17.     fflush(stdin);
  18.     gets(d->dest);
  19.     printf("\nDate: ");
  20.     fflush(stdin);
  21.     gets(d->date);
  22. }
  23.  
  24.  
  25. arbre inserer(arbre a, demande d)
  26. {
  27.     Tnoeud *nv;
  28.     if(a==NULL)
  29.     {
  30.  
  31.         nv=malloc(sizeof(Tnoeud));
  32.         nv->d=d;
  33.         nv->ABG=NULL;
  34.         nv->ABD=NULL;
  35.     }
  36.     else
  37.     {
  38.         if(d.code > a->d.code)
  39.             {
  40.                 a->ABD=inserer(a->ABD,d);
  41.             }
  42.         else
  43.             {
  44.                 a->ABG=inserer(a->ABG,d);
  45.             }
  46.             return(a);
  47.     }
  48. }
  49.  
  50.  
  51. int main()
  52. {
  53.     int choix;
  54.     demande d;
  55.     arbre a;
  56.     do
  57.     {
  58.         do
  59.         {
  60.             printf("\nChoix: 1. Inserer: \n");
  61.             scanf("%d",&choix);
  62.         }while((choix < 0)||(choix>4));
  63.  
  64.         switch(choix)
  65.         {
  66.             case 1: saisir(&d);
  67.                     a=inserer(a, d);
  68.  
  69.  
  70.             break;
  71.         }
  72.     }while(!(choix == 0));
  73.  
  74.  
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement