You are viewing a single comment's thread. Return to all comments →
Slightly cleaner and more readable:
int diag1 = 0, diag2 = 0;
for(int p = 0; p<n; p++)
diag1 += a[p][p];
diag2 += a[p][n - (p + 1)];
can u please explain why n-j-1...
because n will be length and always +1 than index