Ответ:
--- Python 3.7 ---
def MatrixRead(Rows, RowLength, ContType):
for row in range(Rows):
print('Enter line ' + str(row))
buff = []
[buff.append(ContType(input())) for _ in range(RowLength)]
yield buff
def MatrixSwap(Matrix, OldPos:tuple, NewPos: tuple):
Matrix[OldPos[0]][OldPos[1]], Matrix[OldPos[1]][OldPos[0]] = Matrix[NewPos[1]][NewPos[0]], Matrix[NewPos[0]][NewPos[1]]
return Matrix
def MatrixPrint(Matrix, end = '\n'):
for Row in Matrix:
print(*Row, end ='\n')
print(end)
def main():
N = int(input()) #Matrix Size
Matr =list( MatrixRead(N, N, int))
MatrixPrint(Matr) #For check
for row in range(N):
for col in range(N):
SecDiagPos = (row, N-col-1)
MainDiagPos = (row, col)
Matr = MatrixSwap(Matr, MainDiagPos, SecDiagPos)
MatrixPrint(Matr)
if __name__ == '__main__':
main()
Объяснение: