generate functionFri, 10 Feb 2023

The input is a natural number n — the number of rows and columns in the square matrix. Next, the elements of the matrix are entered line by line with a space. Output the maximum element located on the main diagonal and below the main diagonal

def main_diagonal(n): a = [] for i in range(n): a.append([0]*n) for i in range(n): a[i] = input().split() max_el = int(a[0][0]) for i in range(n): for j in range(n): if i > j and int(a[i][j]) > max_el: max_el = int(a[i][j]) return max_el main_diagonal(4)

Questions about programming?Chat with your personal AI assistant