cambiar for por do while
Publicado por Elias (6 intervenciones) el 04/11/2020 02:39:23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
using namespace std;
main () {
int ren, col;
cout << "Indicar el numero de renglones: ";
cin >> ren;
cout << "Indicar el numero de columnas: ";
cin >> col;
float matriz [ren][col + 1];
for (int i = 0; i < ren; i++)
for (int j = 0; j < col; j++) {
cout << "Indicar el valor de (" << i + 1 << "," << j + 1 << "): ";
cin >> matriz [i][j];
}
float suma;
for (int i = 0; i < ren; i++) {
suma = 0;
for (int j = 0; j < col; j++)
suma = suma + matriz [i][j];
matriz [i][col] = suma / col;
}
for
(int i = 0; i < ren; i++)
cout << "Promedio renglon " << i + 1 << ": " << matriz[i][col] << endl;
}
Valora esta pregunta


-1