Advertisement
Guest User

Pizza1

a guest
Oct 16th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. #include<stdio.h>
  2. int LeeControlDatoI(int,int);
  3. float LeeControlDatoF(float,float);
  4. void CargarPizza(int[],float[],int);
  5. int BusquedaPizza(int[],int,int);
  6. void MostrarRecaudacion(int[],float[][6],int,int);
  7. void MostrarMoto(int[],int);
  8. int Maximo(int[],int);
  9. void InformeMaximo(int[],int,int);
  10. void InformeNoPedido(int[],float[][6],int,int);
  11. main()
  12. {
  13. int cod[45],cantviaj[6]={0};
  14. int ticket,pizza,pos,moto,max,cant;
  15. float pre[45],recau[45][6]={{0}};
  16. float impo;
  17. CargarPizza(cod,pre,45);
  18. printf("\n Ingrese numero de ticket: ");
  19. scanf("%d", &ticket);
  20. while(ticket!=0)
  21. {
  22. printf("\n Ingrese codigo de pizza: ");
  23. scanf("%d",&pizza);
  24. pos=BusquedaPizza(cod,pizza,45);
  25. if(pos>=0)
  26. {
  27. moto=LeeControlDatoI(1,6);
  28. printf("\n Ingrese la cantidad pedida");
  29. scanf("%d",&cant);
  30. impo=pre[pos]*cant;
  31. if(cant>3)
  32. impo=impo*0,9;
  33. recau[pos][moto-1]+=impo;
  34. cantviaj[moto-1]++;
  35. }
  36. else
  37. {
  38. printf("\n Error Pizza");
  39. }
  40. printf("\n Ingrese otro numero de ticket: ");
  41. scanf("%d", &ticket);
  42. }
  43. MostrarRecaudacion(cod,recau,45,6);
  44. MostrarMoto(cantviaj,6);
  45. max=Maximo(cantviaj,6);
  46. InformeMaximo(cantviaj,max,6);
  47. InformeNoPedido(cod,recau,45,6);
  48. }
  49. //////////////////////////////////////////////////////////
  50. int LeeControlDatoI(int Li, int Ls)
  51. { int dato;
  52. do
  53. {
  54. printf ("\n Ingrese dato: ");
  55. scanf("%d",&dato);
  56. }while((dato<Li)||(dato>Ls));
  57. return(dato);
  58. }
  59. /////////////////////////////////////////////////////////
  60. float LeeControlDatoF(float Li, float Ls)
  61. { float dato;
  62. do
  63. {
  64. printf ("\n Ingrese dato: ");
  65. scanf("%f",&dato);
  66. }while((dato<Li)||(dato>Ls));
  67. return(dato);
  68. }
  69. ////////////////////////////////////////////////////////
  70. void CargarPizza (int Pi[],float Pr[],int n)
  71. {
  72. int i;
  73. for(i=0;i=n-1;i++)
  74. printf("\n Ingrese codigo de la pizza: ");
  75. Pi[i]=LeeControlDatoI(100,999);
  76. printf("\n Ingrese el precio de la pizza: ");
  77. Pr[i]=LeeControlDatoF(1,1000);
  78. }
  79. ///////////////////////////////////////////////////////
  80. int BusquedaPizza(int V[], int x, int n)
  81. {
  82. int i=0;
  83. int p=-1;
  84. while((p==-1)&&(i<n))
  85. if(V[i]==x)
  86. {
  87. p=i;
  88. }
  89. else
  90. {
  91. i++;
  92. }
  93. return(p);
  94. }
  95. /////////////////////////////////////////////////////
  96. void MostrarRecaudacion(int P[],float R[][6],int f,int c)
  97. {
  98. int i,j,dia,mes;
  99. printf("\n Ingrese dia: ");
  100. dia=LeeControlDatoI(1,31);
  101. printf("\n Ingrese mes: ");
  102. mes=LeeControlDatoI(1,12);
  103. printf("\n Recaudacion de pizza segun moto de reparto");
  104. printf("\n del: ", dia, "/", mes);
  105. printf("\n Codigo de Pizza Moto1 Moto2 ... Moto6");
  106. for(i=0;i=f-1;i++)
  107. {
  108. printf("\n", P[i]);
  109. for(j=0;j=c-1;j++)
  110. printf("\t", R[i][j]);
  111. }
  112. }
  113. /////////////////////////////////////////////////////
  114. void MostrarMoto(int V[],int n)
  115. {
  116. int i;
  117. printf("\n Mostrar viaje por moto");
  118. printf("\n Numero de moto Cant");
  119. for(i=0;i=n-1;i++)
  120. printf("\n", i+1, "\t", V[i]);
  121. }
  122. ///////////////////////////////////////////////////
  123. int Maximo(int V[],int n)
  124. {
  125. int i,max;
  126. max=V[0];
  127. for(i=1;i=n-1;i++)
  128. if(V[i]>max)
  129. max=V[i];
  130. return(max);
  131. }
  132. ///////////////////////////////////////////////////
  133. void InformeMaximo(int V[], int maxi, int n)
  134. {
  135. int i;
  136. printf("\n Maximo de viajes: ", maxi);
  137. for(i=0;i=n-1;i++)
  138. if(V[i]==maxi)
  139. printf("\n Moto: ", i+1);
  140.  
  141. }
  142. ///////////////////////////////////////////////////
  143. void InformeNoPedido(int V[],float M[][6], int f, int c)
  144. {
  145. int i,j,s;
  146. printf("\n Pizzas que no se pidieron: ");
  147. for(i=0;i=f-1;i++)
  148. {
  149. s=0;
  150. for(j=0;j=c-1;j++)
  151. {
  152. s+=M[i][j];
  153. }
  154. if(s==0)
  155. {
  156. printf("\n V[i]");
  157. }
  158. }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement