View Code of Problem 51

#include <iostream>

using namespace std;

const int MAXN = 10;

int arr[MAXN][MAXN];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> arr[i][j];
        }
    }

    int result = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            result += arr[i][j];
        }
    }
    cout << result;
}

Double click to view unformatted code.


Back to problem 51