import random
lst = [[random.randint(10, 99) for _ in range(4)] for p in range(4)]
print('Матрица A:')
for x in lst:
print(*x)
mn = 99
mx = 10
for i in range(len(lst)):
for j in range(len(lst)):
if lst[i][j] >= mx:
mx = lst[i][j]
ind_mx = [i + 1, j + 1]
if lst[i][j] <= mn:
mn = lst[i][j]
ind_mn = [i + 1, j + 1]
print(f'Максимальный элемент A{ind_mx}={mx}')
print(f'Минимальный элемент A{ind_mn}={mn}')
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
import random
lst = [[random.randint(10, 99) for _ in range(4)] for p in range(4)]
print('Матрица A:')
for x in lst:
print(*x)
mn = 99
mx = 10
for i in range(len(lst)):
for j in range(len(lst)):
if lst[i][j] >= mx:
mx = lst[i][j]
ind_mx = [i + 1, j + 1]
if lst[i][j] <= mn:
mn = lst[i][j]
ind_mn = [i + 1, j + 1]
print(f'Максимальный элемент A{ind_mx}={mx}')
print(f'Минимальный элемент A{ind_mn}={mn}')