Problem
Given a square two-dimensional array of size nxn
and a number k
. Print the elements of the k
th diagonal below the main diagonal (i.e. if k=1
, then you need to print the elements of the first diagonal lying below the main one, if k=2
, then the second diagonal, etc.).
The k
value can be negative, for example, if k=−1
, then you need to print the value of the first diagonal lying above the main one. If k=0
, then print the elements of the main diagonal.
Input data
The program receives a number n (n <= 10)
as input, followed by the elements of the array n
lines of n
characters per line, then on a new line, number k
(all elements and value k
modulo no more than 100)
.
Imprint
Elements of the
k
th diagonal below the main diagonal, separated by a space, on the same line.
Examples
# |
Input |
Output |
1 |
4
1 2 3 4
5 6 7 8
0 1 2 3
4 5 6 7
1 |
5 1 6 |
2 |
4
1 2 3 4
5 6 7 8
0 1 2 3
4 5 6 7
-2 |
3 8 |