View Code of Problem 51

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[][] a =new int[n][n];
		int sum = 0;
		for(int i = 0;i < n; i++) {
			for (int j = 0; j< n;j++) {
				a[i][j]=scanner.nextInt();
				if(i >= j) {
					sum += a[i][j];
				}
			}
		}
		System.out.println(sum);
		
	}
}

Double click to view unformatted code.


Back to problem 51