You are viewing a single comment's thread. Return to all comments →
I have solve using java
public static void main(String[] args) {
Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[][] = new int[n][n]; int d1sum = 0; int d2sum = 0; for(int a_i=0; a_i < n; a_i++){ for(int a_j=0; a_j < n; a_j++){ a[a_i][a_j] = in.nextInt(); if(a_j == a_i){ d1sum += a[a_i][a_j]; } if(a_i == n-a_j-1){ d2sum += a[a_i][a_j]; } } } int diff = d1sum-d2sum; System.out.println(Math.abs(diff)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
I have solve using java
public static void main(String[] args) {