-
Notifications
You must be signed in to change notification settings - Fork 2
/
#80
82 lines (57 loc) · 1.53 KB
/
#80
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Создать прямоугольную матрицу A, имеющую N строк и M столбцов со случайными элементами.
Разделить элементы матрицы на элемент матрицы с наибольшим значением.
import random
N = 7
M = 9
L = 2
def get_row(column):
col = []
for i in range(0, column):
col.append(random.randint(0, 99))
return col
def get_matrix(row, column):
matrix = []
for i in range(0, row):
matrix.append(get_row(column))
return matrix
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
def get_column(matrix, index):
column = []
i = 0
while i < len(matrix):
column.append(matrix[i][index])
i += 1
return column
A = get_matrix(N, M)
print("Исходная матрица:")
print_matrix(A)
max_element = False
i = 0
while i < len(A):
j = 0
while j < len(A[i]):
if max_element is False or max_element < A[i][j]:
max_element = A[i][j]
j += 1
i += 1
i = 0
while i < len(A):
j = 0
while j < len(A[i]):
A[i][j] /= max_element
A[i][j] = round(A[i][j], 1)
j += 1
i += 1
print("Максимальный элемент:", max_element)
print("Модифицированная матрица:")
print(matrix(A))