#include <stdio.h>
//Definición de funciones
void cargar (int [4][3]);
int total_trim (int [4][3]);
void total_edad (int [4][3]);
void total_mes (int [4][3]);
int mes_mayor (int [4][3]);
int main()
{
int matriz[4][3]={0};
int total_trimestre, mayor;
cargar(matriz);
total_trimestre = total_trim(matriz);
total_edad(matriz);
total_mes(matriz);
mayor = mes_mayor(matriz);
printf("El total de enfermos en el trimestre fue de: %d\n\n",total_trimestre);
printf("El mes con mayor cantidad de enfermos fue el mes: %d\n\n", mayor);
}
void cargar (int matriz[4][3])
{
int f, c;
for(f=0 ; f<4 ; f++)
{
if(f==0)
printf("Ingrese la cantidad de ninnos del mes de \n");
if(f==1)
printf("Ingrese la cantidad de jovenes del mes de \n");
if(f==2)
printf("Ingrese la cantidad de adultos del mes de \n");
if(f==3)
printf("Ingrese la cantidad de ancianos del mes de \n");
for(c=0 ; c<3 ; c++)
{
if(c==0)
{
printf("enero: ");
scanf("%d",&matriz[f][c]);
}
if(c==1)
{
printf("febrero: ");
scanf("%d",&matriz[f][c]);
}
if(c==2)
{
printf("marzo: ");
scanf("%d",&matriz[f][c]);
}
}
}
}
int total_trim (int matriz[4][3])
{
int suma_total=0, f, c;
for(f=0 ; f<4 ; f++)
{
for(c=0 ; c<3 ; c++)
{
suma_total = suma_total + matriz[f][c];
}
}
return suma_total;
}
void total_edad (int matriz[4][3])
{
int f, c, total=0;
for(f=0 ; f<4 ; f++)
{
total=0;
for(c=0 ; c<3 ; c++)
{
total = total + matriz[f][c];
}
printf("El total de (%d) en el trimestre fue de: %d\n\n", f+1, total);
}
}
void total_mes (int matriz[4][3])
{
int f, c, total=0;
for(c=0 ; c<3 ; c++)
{
total=0;
for(f=0 ; f<4 ; f++)
{
total = total + matriz[f][c];
}
printf("El total de enfermos en el mes %d fue de: %d\n\n", c+1, total);
}
}
int mes_mayor (int matriz[4][3])
{
int f, c, suma, mayor=0, mes=0;
for(c=0 ; c<3 ; c++)
{
suma=0;
for(f=0 ; f<4 ; f++)
{
suma=suma+matriz[f][c];
}
if(suma > mayor)
{
mes = c+1;
mayor = suma;
}
}
return mes;
}
Comments