#include <iostream>
#include <cstdlib>

using namespace std;

int M = 5;
int N = 9;

//==========================================================
int main() {
    int A = 100;
    int B = 999;
    int PAGOS[M][N];
    int TOTAL1[N];
    double PROMEDIO1[N];
    int TOTAL2[M];
    double PROMEDIO2[M];

    system("cls");

    //Cargar Matriz
    for(int i = 0; i <= M - 1; i++) {
        for(int j = 0; j <= N - 1; j++) {
            PAGOS[i][j] = A + rand() % (B - A + 1);
        }
    }

    //Calcular Suma y Promedio Horizontal
    for(int j = 0; j <= N - 1; j++) {
        TOTAL1[j] = 0;
        for(int i = 0; i <= M - 1; i++) {
            TOTAL1[j] = TOTAL1[j] + PAGOS[i][j];
        }
        PROMEDIO1[j] = (1.0 * TOTAL1[j]) / M;
    }

    //Calcular Suma y Promedio Vertical
    for(int i = 0; i <= M - 1; i++) {
        TOTAL2[i] = 0;
        for(int j = 0; j <= N - 1; j++) {
            TOTAL2[i] = TOTAL2[i] + PAGOS[i][j];
        }
        PROMEDIO2[i] = 1.0 * TOTAL2[i] / N;
    }

    //Visualizar Estructuras
    for(int i = 0; i <= M - 1; i++) {
        for(int j = 0; j <= N - 1; j++) {
            cout << PAGOS[i][j] << "\t";
        }
        cout << "|\t" << TOTAL2[i] << "\t";
        cout << PROMEDIO2[i] << "\n";
    }
    cout << "-------------------------------------------------------------------------------------------\n";
    for(int j = 0; j <= N - 1; j++) {
        cout << TOTAL1[j] << "\t";
    }
    cout << "\n";
    for(int j = 0; j <= N - 1; j++) {
        cout << PROMEDIO1[j] << "\t";
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: