generate functionFri, 10 Feb 2023

Write a program that prints the maximum element of a square matrix below the main diagonal. The elements of the main diagonal are also taken into account. The input is a natural number n — the number of rows and columns in the matrix, the number of matrix elements (integers) line by line separated by a space.

def diagonal(n): list = [] for i in range(n): list.append(input().split(" ")) for i in range(n): for j in range(n): list[i][j] = int(list[i][j]) max = 0 for i in range(n): for j in range(n): if i > j and max < list[i][j]: max = list[i][j] return max

Questions about programming?Chat with your personal AI assistant