Advertisement
ProToTN

Untitled

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