generate functionTue, 07 Mar 2023

The program takes two natural numbers as input. n and m are the number of rows and columns in the matrix, then n lines of m integers each, separated by a space character. Write a program that finds the indices (row and column) of the first occurrence of the maximum element. Input Data Format Two numbers n and m are given as input to the program on different lines — the number of rows and columns in the matrix, then the matrix elements themselves row by row separated by a space.

n=int(input()) m=int(input()) max_ind = 0 max_row = 0 max_val = -1 for i in range(n): row = list(map(int, input().split())) for j in range(m): if row[j] > max_val: max_ind = j max_row = i max_val = row[j] print(max_row, max_ind)

Questions about programming?Chat with your personal AI assistant