Привет. Код для задачи Н3.arr = [[1, -2, 3, -4, 5],
[-6, 7, -8, 9, 10],
[11, 12, -13, 14, 15],
[16, -17, 18, -19, 20],
[21, -22, 23, 24, -25]]
max_negatives = 0
row_with_max_negatives = 0
for i in range(len(arr)):
negatives_in_row = 0
for j in range(len(arr[i])):
if arr[i][j] < 0:
negatives_in_row += 1
if negatives_in_row > max_negatives:
max_negatives = negatives_in_row
row_with_max_negatives = i
print("Строчка с максимальным количеством отрицательных чисел:", arr[row_with_max_negatives])
print("Количество отрицательных чисел:", max_negatives)Задача Н4arr = [[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25]]
max_odd = 0
col_with_max_odd = 0
for j in range(len(arr[0])):
odd_in_col = 0
if arr[i][j] % 2 != 0:
odd_in_col += 1
if odd_in_col > max_odd:
max_odd = odd_in_col
col_with_max_odd = j
print("Столбец с максимальным кол-вом непарных чисел:", [arr[i][col_withmax_odd]])
print("Кол-во непарных чисел:", max_odd)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Привет. Код для задачи Н3.
arr = [[1, -2, 3, -4, 5],
[-6, 7, -8, 9, 10],
[11, 12, -13, 14, 15],
[16, -17, 18, -19, 20],
[21, -22, 23, 24, -25]]
max_negatives = 0
row_with_max_negatives = 0
for i in range(len(arr)):
negatives_in_row = 0
for j in range(len(arr[i])):
if arr[i][j] < 0:
negatives_in_row += 1
if negatives_in_row > max_negatives:
max_negatives = negatives_in_row
row_with_max_negatives = i
print("Строчка с максимальным количеством отрицательных чисел:", arr[row_with_max_negatives])
print("Количество отрицательных чисел:", max_negatives)
Задача Н4
arr = [[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25]]
max_odd = 0
col_with_max_odd = 0
for j in range(len(arr[0])):
odd_in_col = 0
for i in range(len(arr)):
if arr[i][j] % 2 != 0:
odd_in_col += 1
if odd_in_col > max_odd:
max_odd = odd_in_col
col_with_max_odd = j
print("Столбец с максимальным кол-вом непарных чисел:", [arr[i][col_withmax_odd]])
print("Кол-во непарных чисел:", max_odd)