Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct Tas *PTasmax;
- typedef struct Commande * PCommande;
- typedef struct Commande
- {
- int unsigned NCommande;
- char DateCommande[11];
- int unsigned NumClient;
- char NomClient[25],PrenomClient[25];
- char AdresseClient[25];
- int unsigned QuantiteCommande;
- char etat;
- }Commande;
- typedef struct Tas
- {
- int ind;
- PCommande T;
- }Tas;
- void AfficherTas(PTasmax T)
- {
- int i;
- for(i=0;i<=T->ind;i++)
- {
- printf("\n -------------------------------------------- ");
- printf("\n |- Numero Commande : %u",T->T[i].NCommande);
- printf("\n |- Quantite Commande : %u",T->T[i].QuantiteCommande);
- printf("\n |- Date de Commande Client : %s ",T->T[i].DateCommande);
- printf("\n |- Numero Client : %u ",T->T[i].NumClient );
- printf("\n |- Nom Client : %s ",T->T[i].NomClient);
- printf("\n |- Prenom Client : %s ",T->T[i].PrenomClient);
- printf("\n |- Adress Client : %s ",T->T[i].AdresseClient);
- printf("\n -------------------------------------------- ");
- }
- }
- int Pere(int Pos,PTasmax Tasmax){
- div_t temp;
- temp = div(Pos,2);
- if(Pos % 2 ==0)
- {return ((temp.quot)-1);}
- else
- {return (temp.quot);}
- }
- int Qcommande(int Pos,PTasmax Tasmax){return Tasmax->T[Pos].QuantiteCommande;}
- void InsererTmax(Commande V,PTasmax Tasmax)
- {
- int i,p;
- i = Tasmax->ind;
- p = Pere(i,Tasmax);
- while(i>0 && V.QuantiteCommande > Qcommande(p,Tasmax))
- {
- Tasmax->T[i] = Tasmax->T[p];
- i = p;
- p = Pere(i,Tasmax);
- }
- Tasmax->T[i] = V;
- }
- void ajouteT(PTasmax Tasm){
- Commande V;
- // SAISIE DE LA COMMANDE
- printf(" \n Entre Nom Client : ");
- scanf("%s",&V.NomClient);
- printf(" \n Entre Prenom Client : ");
- scanf("%s",&V.PrenomClient);
- printf("\n |- Numero Client : ");
- scanf("%u",&V.NumClient);
- printf("\n |- Numero Commande : ");
- scanf("%u",&V.NCommande);
- printf("\n |- Quantite Commande :");
- scanf("%u",&V.QuantiteCommande);
- printf("\n |- Date de Commande Client : ");
- scanf("%s",&V.DateCommande);
- printf("\n |- Adress Client : ");
- scanf("%s",&V.AdresseClient);
- V.etat = 'c';
- //FIN DE LA SAISIE
- //IF
- if(Tasm->T == NULL)
- {
- Tasm->ind = Tasm->ind+1;
- Tasm->T = calloc(1,sizeof(Commande));
- }else
- {
- Tasm->ind = Tasm->ind+1;
- Tasm->T = realloc(Tasm->T,Tasm->ind+1 * sizeof(Commande));
- }
- //END IF
- //INSERTION PAR LA PROCEDURE INSERERTMAX
- InsererTmax(V,Tasm);
- //FIN INSERTION
- }
- void PagePrincipale();
- int main()
- {
- PTasmax Tasm;
- int i;
- Tasm = (PTasmax)malloc(sizeof(Tas));
- Tasm->T = NULL;
- Tasm->ind = -1;
- ajouteT(Tasm);
- ajouteT(Tasm);
- ajouteT(Tasm);
- AfficherTas(Tasm);
- return 0;
- }
- void PagePrincipale()
- {
- int j;
- system("cls");
- printf("|----------------------------------------------------------------------------|\n");
- printf("|[1]- Saisir d'une ou de plusieurs Commandes . |\n");
- printf("|[2]- Afficher les info de la commande qui contient la plus grande quantite .|\n");
- printf("|[3]- La Modification de la quantite commandee d'une commande . |\n");
- printf("|[4]- Afficher le nombre de commandes en attente de traitement . |\n");
- printf("|[5]- Afficher de la quantite totales des commandes en attente de traitement.|\n");
- printf("|[6]- Afficher de la liste des commandes . |\n");
- printf("|[7]- Sortir Du Programme . |\n");
- printf("|----------------------------------------------------------------------------|\n");
- for(j=0;j<=7;j++){ printf("\n"); }
- printf(" Programmer Par : Oussama Abdellah. \n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement