Вы находитесь на странице: 1из 3

#include <stdio.

h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#define max 100
using namespace std;
int i,j;

void ingrese(int a[12][15])


{
for (i=0;i<12;i++)
{cout<<"\nINGRESE GASTO DEL MES "<<"("<<i+1<<")"<<endl;
cout<<"------------------------"<<endl<<endl;
for (j=0;j<15;j++)
{cout<<" RUBRO " <<j+1<<": ";
do
{cin>>a[i][j];
}while(a[i][j]<0);
}
}
}
//-------------------------------------------------------------
void gastos_anual(int a[12][15],int b[max])
{
int total;
for (j=0;j<15;j++)
{total=0;
for (i=0;i<12;i++)
total=total+a[i][j];
b[j]=total;
}
}
//-------------------------------------------------------------
void mostrar_anual(int b[max])
{ cout<<endl<<endl;
cout<<"a) GASTOS ANUALES POR RUBRO (GAPR): "<<endl;
cout<< "-------------------------------"<<endl<<endl;
for(j=0;j<15;j++)
{cout<<"RUBRO"<<j+1<< "="<<b[j]<<endl;}
getch();
}
//--------------------------------------------------------------
void mes(int a[12][15],int b[max])
{
int total;
for (i=0;i<12;i++)
{total=0;
for (j=0;j<15;j++)
total=total+a[i][j];
b[i]=total;
}
cout<<endl<<endl;
cout<<"b) GASTOS MENSUALES EN TODO LOS RUBROS (GM): "<<endl;
cout<<" ----------------------------------------"<<endl<<endl;;
for(i=0;i<12;i++)
{cout<<"Mes"<<i+1<< "="<<b[i]<<endl;}
getch();
}
//--------------------------------------------------------------
void mayor_anual(int b[max])
{
int mayor=b[j],total=0;
for(j=0;j<15;j++)
{
if(b[j]>mayor)
{mayor=b[j];
total=j;}
}
cout<<endl<<endl;
cout<<"c) EN QUE RUBRO SE DA EL MAYOR GASTO ANUAL?: "<<total+1<<endl;
cout<< "----------------------------------------"<<endl<<endl;
getch();
}
//---------------------------------------------------------------
void menor_anual(int b[max])
{
int menor=b[j],total=0;
for(j=0;j<15;j++)
{
if(b[j]<menor)
{menor=b[j];
total=j;}
}
cout<<endl<<endl;
cout<<"d) EN QUE RUBRO SE DA EL MENOR GASTO ANUAL?: "<<total+1<<endl;
cout<<" ----------------------------------------"<<endl<<endl;
getch();
}
//---------------------------------------------------------------
void mes_mayor(int b[max])
{
int mayor=b[i],total=0;
for(i=0;i<3;i++)
{
if(b[i]>mayor)
{mayor=b[i];
total=i;}

}
cout<<endl<<endl;
cout<<"e) EN QUE MES DURANTE EL A�O SE PRODUJO EL MAYOR GASTO?:
"<<total+1<<endl;
cout<<" ----------------------------------------------------"<<endl<<endl;
getch();
}
//---------------------------------------------------------------
int main()
{int gastos[12][15],GAPR[max],GM[max];
cout<<setw(8)<<" *******************************"<<endl;
cout<<setw(8)<<" * GASTOS (ANUAL - MENSUAL) *"<<endl;
cout<<setw(8)<<" * ------------------------ *"<<endl;
cout<<setw(8)<<" * |||En los 15 Rubros|||| "<<endl;
cout<<setw(8)<<" *******************************"<<endl<<endl;
ingrese(gastos);
gastos_anual(gastos,GAPR);
mostrar_anual(GAPR);
mes(gastos,GM);
mayor_anual(GAPR);
menor_anual(GAPR);
mes_mayor(GM);
getch();
return 0;
}

Вам также может понравиться