Advertisement
ProToTN

Untitled

Jan 4th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. void trouver(gateau tabG[],int tg,int type,int *pos)
  2. {
  3.     int i,v=0;
  4.     for(i=0;i<tg;i++)
  5.     {
  6.         if((v==0)&&(tabG[i].type==type))
  7.         {
  8.             *pos=i;
  9.             v=1;
  10.         }
  11.     }
  12. }
  13.  
  14.  
  15. float calculerPrix(gateau g)
  16. {
  17.     int i=0,p;
  18.     float prix;
  19.     for(i=0;i<g.nbIngredients;i++)
  20.     {
  21.         prix=prix+(g.tabI[i].quantity*g.tabI[i].price);
  22.     }
  23.     switch(g.type)
  24.     {
  25.         case 0:
  26.         p=20;
  27.         break;
  28.         case 1:
  29.         p=10;
  30.         break;
  31.         case 2:
  32.         p=15;
  33.         break;
  34.     }
  35.     prix=(prix*100)/p;
  36.     return prix;
  37. }
  38.  
  39.  
  40. void vendre(int matV[][7],gateau tabG[],int type,int jour,int *tg,float tabP[])
  41. {
  42.     int i,pos;
  43.     gateau g;
  44.     trouver(tabG,*tg,type,&pos);
  45.     g=tabG[pos];
  46.     tabP[jour]=tabP[jour]+calculerPrix(g);
  47.     matV[jour][g.type]=matV[jour][g.type]+1;
  48.     for (i=pos;i<(*tg);i++)
  49.     {
  50.         tabG[i]=tabG[i+1];
  51.     }
  52.     (*tg)=(*tg)-1;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement