Elements of anti diagonal
Input
3
123
456
789
def read_matrix():
n = int(input())
M = []
for i in range(n):
line = input()
row = [int(s) for s in line.split()]
M.append(row)
return M
def antidiagonal(M):
n = len(M)
L = []
for i in range(n):
x = M[i][n-1-i]
L.append(x)
return L
def main():
M = read_matrix()
D = antidiagonal(M)
for x in D:
print(x, end=' ')
main()
Comments
Leave a comment