View Code of Problem 51

#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int h = n;
	int arr[10][10];
	int sum = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < h; j++) {
			scanf("%d", &arr[i][j]);
		}
	}
	for (int i = h-1; i >= 0; i--) {
		for (int j =0; j <= i; j++) {
			sum += arr[i][j];
			//cout << arr[i][j] <<endl;
		}
	}
	cout << sum;
}

Double click to view unformatted code.


Back to problem 51