Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1: #include <iostream>

2: #include <cmath>
3:
4:
5:
6: using namespace std;
7:
8: string Dia[7] = { "Lunes" , "Martes" , "Miercoles" , "Jueves" , "Viernes" ,"Sabado" , "Domingo
9:
10: void Leer(int &M);
11: bool Validar (const int M);
12: void Leer (const int M, const int N, float** Mat);
13: float Suma (const int M, const int N, float** Mat, float *Vector3);
14: void Total(const int M, const int N, float *Vector3, float *Vector2);
15: void Imprimir(const int M, const int N, float** Mat,float *Vector2, float *Vector3 );
16:
17:
18: int main (void)
19: {
20: int M, i;
21: int N= 7;
22: float **Mat;
23: float *Vector2;
24: float *Vector3;
25: float *Dia;
26:
27: Leer (M);
28:
29: Mat= new float *[M];
30: Vector2= new float [M];
31: Vector3= new float [M];
32:
33: for (i=0; M>i; i++)
34: {
35: Mat [i]= new float [N];
36: }
37:
38: Leer( M, N, Mat);
39:
40: Suma( M, N, Mat, Vector3 );
41:
42:
43: Total( M, N, Vector3, Vector2);
44:
45: Imprimir (M, N, Mat, Vector2, Vector3);
46:
47: delete [] Mat;
48: delete [] Vector2;
49: delete [] Vector3;
50: }
51:
52:
53: void Leer(int &M)
54: {
55: cout<<endl<<"Ingresa el numero de personas: ";
56: cin>>M;
57: while (Validar (M)==true)
58: {
59: system ("cls");
60: cout<<endl<<"Valor Erroneo"<<endl;
61: cout<<endl<<"Ingrese un numero mayor a 0: "<<endl;
62: cin>>M;
63: }
64: }
65:
66: bool Validar (const int M)
67: {
68: bool V= true;
69:
70: if(M<=0);
71:
72: else
73:
74: V= false;
75:
76: return V;
77:
78: }
79:
80:
81:
82: void Leer (const int M, const int N, float** Mat)
83:
84: {
85: system ("cls");
86: int i, j, S;
87:
88: cout<<endl<< "\tINGRESE LOS KILLOWATS" << endl;
89: cout<<endl;
90:
91: for( i=0, S=1; M>i; i++, S++)
92: {
93: cout<<"Persona "<<S<<" "<<endl;
94: cout<<endl;
95: for( j=0; N>j; j++)
96: {
97: cout<<Dia[j]<<": ";
98:
99: cin>> Mat [i] [j];
100: cout<<endl;
101: }
102: cout<<endl;
103: }
104: }
105:
106: float Suma (const int M, const int N, float** Mat, float *Vector3)
107: {
108: int i, j, S;
109:
110: for( i=0, S=1; M>i; i++, S++ )
111: {
112: for( j=0; N>j; j++ )
113: {
114: Vector3[i] = Vector3[i] + Mat[i][j];
115:
116: }
117:
118: }
119:
120: }
121:
122: void Total(const int M, const int N, float *Vector3, float *Vector2)
123: {
124: int i, j, S;
125:
126: for( i=0, S=1; M>i; i++, S++ )
127: {
128:
129: Vector2[i] = Vector3[i]*7.50;
130: }
131: }
132:
133:
134: void Imprimir(const int M, const int N, float** Mat,float *Vector2, float *Vector3 )
135: {
136: system ("cls");
137: cout<<endl<<"Los KILLOWATTS gastados en la semana fueron los siguientes"<<endl;
138: cout<<endl;
139:
140: int i, j, S;
141:
142: for( i=0, S=1; M>i; i++, S++ )
143: {
144:
145: for( j=0; N>j; j++ )
146: {
147: cout<<" \t "<< Dia[j]<<": ";
148: cout<<Mat[i][j];
149:
150:
151:
152: }
153: cout<<endl;
154: }
155:
156: cout<<endl<<"LA SUMA TOTAL DE CADA PERSONA FUE DE"<<endl;
157: cout<<endl;
158: for( i=0, S=1; M>i; i++, S++ )
159: {
160:
161: cout<<"\tPERSONA "<<S<<": "<<Vector3[i]<<" Killowatts"<<endl;
162: cout<<endl;
163:
164: }
165: cout<<endl<<"EL COSTO TOTAL ES DE"<<endl;
166: cout<<endl;
167: for( i=0, S=1; M>i; i++, S++ )
168: {
169:
170: cout<<"\tPERSONA "<<S<<": "<<Vector2[i]<<endl;
171: }
172:
173: }
174:
175:
176:
177:
178:
179:

You might also like