View Code of Problem 51

#include<bits/stdc++.h> 
using namespace std;

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

Double click to view unformatted code.


Back to problem 51