View Code of Problem 51

#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,j,arr[n][n];
	for(i = 0; i < n; i ++){
		for(j = 0; j < n; j ++){
			scanf("%d",&arr[i][j]);
		}
	}
	int sum = 0;
	for(i = 0; i < n; i ++){
		for(j = 0; j < n; j ++){
			if(j > i){
				break;
			}
			sum += arr[i][j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 51