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 it

def find_max(n, matrix): max_num = matrix[0][0] for i in range(n): for j in range(i + 1, n): if matrix[i][j] > max_num: max_num = matrix[i][j] return max_num n = int(input()) matrix = [] for i in range(n): matrix.append([int(i) for i in input().split()]) print(find_max(n, matrix))

Questions about programming?Chat with your personal AI assistant