Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- void f_cargar (int [4][12]);
- void f_mostrar_matriz (int [4][12]);
- void f_suc_may_anual (int [4][12]);
- void f_suc_mes_men_fac (int [4][12]);
- void f_prom_mes (int [4][12]);
- int main ()
- {
- int matriz[4][12];
- f_cargar(matriz);
- f_mostrar_matriz(matriz);
- f_suc_may_anual(matriz);
- f_suc_mes_men_fac(matriz);
- f_prom_mes(matriz);
- return 0;
- }
- void f_cargar (int A[4][12])
- {
- int f, c;
- srand(time(0));
- for(f=0 ; f<4 ; f++)
- {
- for(c=0 ; c<12 ; c++)
- {
- //Esto es para que lo cargue el usuario
- //printf("Ingrese la facturacion del mes %d y de la sucursal %d: ",c , f);
- //scanf("%d", &A[f][c]);
- //Cargado aleatorio automatico
- A[f][c]=rand()%100+1;
- }
- }
- }
- void f_mostrar_matriz (int A[4][12])
- {
- int f, c;
- for(f=0 ; f<4 ; f++)
- {
- for(c=0 ; c<12 ; c++)
- {
- printf("%d ", A[f][c]);
- }
- printf("\n");
- }
- printf("\n\n\n");
- }
- void f_suc_may_anual (int M[4][12])
- {
- int f, c, suma, mayor=0, sucursal;
- for(f=0 ; f<4 ; f++)
- {
- suma=0;
- for(c=0 ; c<12 ; c++)
- {
- suma = suma + M[f][c];
- if(suma > mayor)
- {
- mayor = suma;
- sucursal = f + 1;
- }
- }
- }
- printf("La sucursal con mayor facturacion anual fue la %d con una facturacion de %d\n\n", sucursal, mayor);
- }
- void f_suc_mes_men_fac (int B[4][12])
- {
- int f, c, menor=999999, sucursal, mes;
- for(f=0 ; f<4 ; f++)
- {
- for(c=0 ; c<12 ; c++)
- {
- if(B[f][c] < menor)
- {
- menor = B[f][c];
- sucursal = f + 1;
- mes = c + 1;
- }
- }
- }
- printf("La menor facturacion fue de $%d en el mes de %d en la sucursal numero %d\n\n", menor, mes, sucursal);
- }
- void f_prom_mes (int C[4][12])
- {
- int f, c, promedio;
- for(c=0 ; c<12 ; c++)
- {
- promedio = 0;
- for(f=0 ; f<4 ; f++)
- {
- promedio = promedio + C[f][c];
- }
- promedio = promedio / 4;
- printf("El promedio de ventas del mes %d fue de: %d\n", c+1, promedio);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment