0
Secondary diagonal in 2D array
how to find the summation of the variables in the secondary diagonal of an array with c++ program?
4 Respuestas
+ 8
What's a secondary diagonal?
+ 8
So if you have an array like this:
0,0 0,1 0,2
1,0 1,1 1,2
2,0 2,1 2,2
The secondary diagonal would be 0,2 1,1 2,0 ?
+ 8
If that's the case I would use a nested for loop and check if that for index (i,j) if((i+j)== (n-1)) where n is the number of rows/columns in the array (assuming that it is square). If that is true then add array[i][j] to a variable sum.
0
google it 😒