TheMalva

Ejercicio tipo parcial 2

Oct 6th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. void f_cargar (int [4][12]);
  6. void f_mostrar_matriz (int [4][12]);
  7. void f_suc_may_anual (int [4][12]);
  8. void f_suc_mes_men_fac (int [4][12]);
  9. void f_prom_mes (int [4][12]);
  10.  
  11. int main ()
  12. {
  13.     int matriz[4][12];
  14.     f_cargar(matriz);
  15.     f_mostrar_matriz(matriz);
  16.     f_suc_may_anual(matriz);
  17.     f_suc_mes_men_fac(matriz);
  18.     f_prom_mes(matriz);
  19.     return 0;
  20. }
  21.  
  22. void f_cargar (int A[4][12])
  23. {
  24.     int f, c;
  25.     srand(time(0));
  26.     for(f=0 ; f<4 ; f++)
  27.     {
  28.         for(c=0 ; c<12 ; c++)
  29.         {
  30.             //Esto es para que lo cargue el usuario
  31.             //printf("Ingrese la facturacion del mes %d y de la sucursal %d: ",c , f);
  32.             //scanf("%d", &A[f][c]);
  33.  
  34.             //Cargado aleatorio automatico
  35.             A[f][c]=rand()%100+1;
  36.         }
  37.     }
  38. }
  39.  
  40. void f_mostrar_matriz (int A[4][12])
  41. {
  42.     int f, c;
  43.     for(f=0 ; f<4 ; f++)
  44.     {
  45.         for(c=0 ; c<12 ; c++)
  46.         {
  47.             printf("%d ", A[f][c]);
  48.         }
  49.         printf("\n");
  50.     }
  51.     printf("\n\n\n");
  52. }
  53.  
  54. void f_suc_may_anual (int M[4][12])
  55. {
  56.     int f, c, suma, mayor=0, sucursal;
  57.  
  58.     for(f=0 ; f<4 ; f++)
  59.     {
  60.         suma=0;
  61.         for(c=0 ; c<12 ; c++)
  62.         {
  63.             suma = suma + M[f][c];
  64.             if(suma > mayor)
  65.             {
  66.                 mayor = suma;
  67.                 sucursal = f + 1;
  68.             }
  69.         }
  70.     }
  71.     printf("La sucursal con mayor facturacion anual fue la %d con una facturacion de %d\n\n", sucursal, mayor);
  72. }
  73.  
  74. void f_suc_mes_men_fac (int B[4][12])
  75. {
  76.     int f, c, menor=999999, sucursal, mes;
  77.  
  78.     for(f=0 ; f<4 ; f++)
  79.     {
  80.         for(c=0 ; c<12 ; c++)
  81.         {
  82.             if(B[f][c] < menor)
  83.             {
  84.                 menor = B[f][c];
  85.                 sucursal = f + 1;
  86.                 mes = c + 1;
  87.             }
  88.         }
  89.     }
  90.     printf("La menor facturacion fue de $%d en el mes de %d en la sucursal numero %d\n\n", menor, mes, sucursal);
  91. }
  92.  
  93.  
  94. void f_prom_mes (int C[4][12])
  95. {
  96.     int f, c, promedio;
  97.  
  98.     for(c=0 ; c<12 ; c++)
  99.     {
  100.         promedio = 0;
  101.         for(f=0 ; f<4 ; f++)
  102.         {
  103.             promedio = promedio + C[f][c];
  104.         }
  105.         promedio = promedio / 4;
  106.         printf("El promedio de ventas del mes %d fue de: %d\n", c+1, promedio);
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment