View Code of Problem 51

#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
	int n,sum=0;
	cin>>n;
	int arr[10][10];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			cin>>arr[i][j];
		}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			if(i==j||i<j)
				sum+=arr[i][j];
			
		}
	cout<<sum<<endl;
	
	return 0;
} 

Double click to view unformatted code.


Back to problem 51