-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path67.py
More file actions
66 lines (46 loc) · 1.23 KB
/
67.py
File metadata and controls
66 lines (46 loc) · 1.23 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import random
N = 2 # строк
M = 3 # столбцов
def get_row(column):
col = []
for i in range(0, column):
col.append(random.randint(0, 9))
return col
def get_matrix(row, column):
matrix = []
for i in range(0, row):
matrix.append(get_row(column))
return matrix
def listsum(list):
sum = 0
for element in list:
sum += element
return sum
def print_matrix(matrix):
i = 0
while i < len(matrix):
j = 0
row = matrix[i]
while j < len(row):
column = row[j]
print(column, end=' ')
j += 1
print()
i += 1
A = get_matrix(N, M)
tmp = list(zip(*A))
max_sum = 0
index_column_max_sum = 0
i = 0
while i < len(tmp):
column = tmp[i]
current_list_sum = listsum(column)
if current_list_sum > max_sum:
max_sum = current_list_sum
index_column_max_sum = i
i += 1
print("Матрица:")
print_matrix(A)
print("Cтолбец для которого сумма абсолютных значений элементов максимальна:",
index_column_max_sum)
print("Наибольший элемент этого столбца:", max(tmp[index_column_max_sum]))