Advertisement
Ponja

Verano, ejercicio vector de string y numericos

Feb 24th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <stdlib.h>
  5. int valida (int,int);
  6. void carga (int[],char[][51],float[]);
  7. int buscar (int[],int,int);
  8. void año(float[][12],int,int,int[],char[][51]);
  9. void mes(float[][12],int,int);
  10. void maximo(float[][12],int);
  11. void ordenar(int[],int,int[],char[][51]);
  12.  
  13. int main()
  14. {
  15.     int tot,cod[1000],cant[1000],pos,canti,codi,mes;
  16.     char desc[1000][51];
  17.     float precio[1000],mat[1000][12],tach[12];
  18.  
  19.     tot=carga(cod,desc,precio);
  20.     printf("Ingrese el codigo de producto");
  21.     codi=valida(99,999);
  22.     while(codi!=99)
  23.     {
  24.         pos=buscar(cod,codi,tot);
  25.         if(pos!=-1)
  26.         {
  27.             puts("Ingrese mes de facturazion");
  28.             mes=validar(1,12);
  29.             puts("Ingrese cantidad vendida");
  30.             canti=valida(5,100);
  31.             mat[pos][mes-1]+=canti*precio[pos];
  32.             if(strcmpi(desc[pos],"tachuelas")==0)
  33.             {
  34.                 tach[mes-1]+=canti*precio[pos];
  35.             }
  36.             cant[pos]+=canti;
  37.  
  38.         }else puts("Nose ha encontrado codigo");
  39.  
  40.         printf("Ingrese el codigo de producto");
  41.         codi=valida(99,999);
  42.     }
  43.     año(mat,tot,12,cod,desc);
  44.     mes(mat,tot,12);
  45.     max=maximo(mat,7);
  46.     ordenar(cant,tot,cod,desc);
  47. }
  48.  
  49. ////////////////////////////////////////////////////////////////
  50. int valida(int li,int ls)
  51. {
  52.     int a;
  53.     do
  54.     {
  55.         scanf("%d",&a);
  56.     }while(a<li||a>ls);
  57.     return a;
  58. }
  59.  
  60. /////////////////////////////////////////////////////////////////////////
  61. int carga(int cod[],char desc[][51],float prec[],int t;)
  62. {
  63.     int a,i=0;
  64.     float b;
  65.  
  66.     printf("Ingrese descripcion del produco");
  67.     fflush(stdin);
  68.     gets(desc[i]);
  69.     desc=toupper(desc);
  70.     while(strcmpi(desc[i],"fin")!=0)
  71.     {
  72.         puts("Ingrese Codigo de producto");
  73.         a=valida(100,999);
  74.         do
  75.         {
  76.           puts("Ingrese el precio del producto");
  77.           scanf("%f",&b)
  78.         }while(b<500||b>10000);
  79.         cod[i]=a;
  80.         prec[i]=b;
  81.         i++;
  82.         puts("Ingrese descripcion del produco");
  83.         fflush(stdin);
  84.         gets(desc[i]);
  85.         desc=toupper(desc);
  86.  
  87.     }
  88.     return i;
  89. }
  90.  
  91.  
  92. ////////////////////////////////////////////////
  93. void mes(float mat[][51],int tot,int a)
  94. {
  95.     int i,j;
  96.     float acum=0;
  97.     printf("\nMes\tImporte Total")
  98.     for(j=0;j<a;j++)
  99.     {
  100.         acum=0;
  101.         for(i=0;i<tot;i++)
  102.         {
  103.             acum+=mat[i][j];
  104.         }
  105.         printf("\n%d\t%f",j+1,acum);
  106.     }
  107. }
  108. /////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement