Advertisement
Guest User

Untitled

a guest
Dec 26th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  typedef struct Tas *PTasmax;
  5.     typedef struct Commande * PCommande;
  6.  
  7.     typedef struct Commande
  8.     {
  9.             int unsigned NCommande;
  10.             char DateCommande[11];
  11.             int unsigned NumClient;
  12.             char NomClient[25],PrenomClient[25];
  13.             char AdresseClient[25];
  14.             int unsigned QuantiteCommande;
  15.             char etat;
  16.  
  17.     }Commande;
  18.     typedef struct Tas
  19.     {
  20.             int ind;
  21.             PCommande T;
  22.     }Tas;
  23.  
  24.  
  25.  
  26.  
  27. void AfficherTas(PTasmax T)
  28.     {
  29.             int i;
  30.     for(i=0;i<=T->ind;i++)
  31.             {
  32.  
  33.                     printf("\n  -------------------------------------------- ");
  34.                     printf("\n |- Numero Commande : %u",T->T[i].NCommande);
  35.                     printf("\n |- Quantite Commande : %u",T->T[i].QuantiteCommande);
  36.                     printf("\n |- Date de Commande Client : %s ",T->T[i].DateCommande);
  37.                     printf("\n |- Numero Client : %u ",T->T[i].NumClient );
  38.                     printf("\n |- Nom Client : %s ",T->T[i].NomClient);
  39.                     printf("\n |- Prenom Client : %s ",T->T[i].PrenomClient);
  40.                     printf("\n |- Adress Client : %s ",T->T[i].AdresseClient);
  41.                     printf("\n  -------------------------------------------- ");
  42.             }
  43.     }
  44.  
  45.  
  46.  
  47. int Pere(int Pos,PTasmax Tasmax){
  48. div_t temp;
  49. temp =  div(Pos,2);
  50. if(Pos % 2 ==0)
  51. {return ((temp.quot)-1);}
  52. else
  53. {return (temp.quot);}
  54. }
  55.  
  56. int Qcommande(int Pos,PTasmax Tasmax){return Tasmax->T[Pos].QuantiteCommande;}
  57.  
  58.  
  59. void InsererTmax(Commande V,PTasmax Tasmax)
  60. {
  61.     int i,p;
  62.    i = Tasmax->ind;
  63. p = Pere(i,Tasmax);
  64. while(i>0 && V.QuantiteCommande > Qcommande(p,Tasmax))
  65. {
  66. Tasmax->T[i] = Tasmax->T[p];
  67. i = p;
  68. p = Pere(i,Tasmax);
  69. }
  70. Tasmax->T[i] = V;
  71. }
  72.  
  73.  
  74.  
  75.  void ajouteT(PTasmax Tasm){
  76. Commande V;
  77. // SAISIE DE LA COMMANDE
  78. printf(" \n Entre Nom Client : ");
  79. scanf("%s",&V.NomClient);
  80.  
  81. printf(" \n Entre Prenom Client : ");
  82. scanf("%s",&V.PrenomClient);
  83.  
  84. printf("\n |- Numero Client : ");
  85. scanf("%u",&V.NumClient);
  86.  
  87. printf("\n |- Numero Commande : ");
  88. scanf("%u",&V.NCommande);
  89.  
  90. printf("\n |- Quantite Commande :");
  91. scanf("%u",&V.QuantiteCommande);
  92.  
  93. printf("\n |- Date de Commande Client : ");
  94. scanf("%s",&V.DateCommande);
  95.  
  96. printf("\n |- Adress Client : ");
  97. scanf("%s",&V.AdresseClient);
  98. V.etat = 'c';
  99. //FIN DE LA SAISIE
  100.  
  101.  
  102. //IF
  103.     if(Tasm->T == NULL)
  104.     {
  105.     Tasm->ind = Tasm->ind+1;
  106.     Tasm->T = calloc(1,sizeof(Commande));
  107.     }else
  108.     {
  109. Tasm->ind = Tasm->ind+1;
  110. Tasm->T = realloc(Tasm->T,Tasm->ind+1 * sizeof(Commande));
  111.     }
  112. //END IF
  113.  
  114. //INSERTION PAR LA PROCEDURE INSERERTMAX
  115. InsererTmax(V,Tasm);
  116. //FIN INSERTION
  117.     }
  118.  
  119. void PagePrincipale();
  120.  
  121. int main()
  122. {
  123. PTasmax Tasm;
  124.  
  125.  
  126. int i;
  127.   Tasm = (PTasmax)malloc(sizeof(Tas));
  128.             Tasm->T = NULL;
  129.             Tasm->ind = -1;
  130.  
  131.  
  132.  
  133.  
  134. ajouteT(Tasm);
  135. ajouteT(Tasm);
  136. ajouteT(Tasm);
  137. AfficherTas(Tasm);
  138.  
  139.  
  140.  
  141.  
  142.  
  143. return 0;
  144.  
  145. }
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. void PagePrincipale()
  153. {
  154.     int j;
  155.     system("cls");
  156.         printf("|----------------------------------------------------------------------------|\n");
  157.         printf("|[1]- Saisir d'une ou de plusieurs Commandes .                               |\n");
  158.         printf("|[2]- Afficher les info de la commande qui contient la plus grande quantite .|\n");
  159.         printf("|[3]- La Modification de la quantite commandee d'une commande .              |\n");
  160.         printf("|[4]- Afficher le nombre de commandes en attente de traitement .             |\n");
  161.         printf("|[5]- Afficher de la quantite totales des commandes en attente de traitement.|\n");
  162.         printf("|[6]- Afficher de la liste des commandes .                                   |\n");
  163.         printf("|[7]- Sortir Du Programme .                                                  |\n");
  164.         printf("|----------------------------------------------------------------------------|\n");
  165.         for(j=0;j<=7;j++){ printf("\n"); }
  166.         printf("                         Programmer Par : Oussama Abdellah. \n");
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement