All the points of the diagonal of a matrix

I want to find all the points which are located on the diagonal of the matrix.
The input consists of two parts. One is the number of rows(and columns cuz they are equal) and the other one is the matrix.
For example:
3
1 2 3
4 5 6
7 8 9

The output should be:
1
5
9
Any idea on how to code this idea?
for a square matrix? What are you not seeing... you have been asking one liners a lot, like you are not quite seeing the how of things... We don't mind helping but if you need help making things click maybe you need to step back and ask yourself what was keeping you from coming up with it:

for(r = 0; r < input; r++)
cout << matrix[r][r]; //[0][0], [1][1], [2][2] ..

Last edited on
Topic archived. No new replies allowed.