You are viewing a single comment's thread. Return to all comments →
just in case you didnt know the for loop couldve been written like this for a cleaner look
for(int i = 0, j = n-1; i < n; i++, j--){ sum1 += a[i][i]; sum2 += a[j][i]; }
or as
for(int i = 0; i < n; i++){ sum1 += a[i][i]; sum2 += a[(n-1)-i][i]; }
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 →
just in case you didnt know the for loop couldve been written like this for a cleaner look
or as