-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_3.py
More file actions
55 lines (41 loc) · 1.05 KB
/
_3.py
File metadata and controls
55 lines (41 loc) · 1.05 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
# By Zhufyak V.V
# zhufyakvv@gmail.com
# github.com/zhufyakvv
# 19.09.2017
def getVectorRow(matrix, getRow):
result = []
for i in matrix:
result.append(getRow(i))
return result
def getVectorCol(matrix, getCol):
result = []
for i in range(0, len(matrix[0])):
tmp = []
for j in range(0, len(matrix)):
tmp.append(matrix[j][i])
result.append(getCol(tmp))
return result
def getVectorSum(vector):
result = 0
for i in vector:
result += i
return result
def printBy(array, amount=5):
line = ""
for key, value in enumerate(array):
line += str(value) + " "
if (key + 1) % amount == 0:
print(line)
line = ""
print(line)
n = int(input("Set size of matrix..."))
n = 15 if n > 15 else n
matrix = []
for i in range(0, n):
matrix.append([])
for j in range(0, n):
matrix[i].append(int(input()))
resultA = getVectorRow(matrix, getVectorSum)
resultB = getVectorCol(matrix, getVectorSum)
printBy(resultA)
printBy(resultB)