-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColumnMatrix.py
48 lines (37 loc) · 1.07 KB
/
ColumnMatrix.py
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
class ColumnMatrix:
def __init__(self, rows, columns):
self.rows = rows
self.columns = columns
self.matrix = []
for i in range(columns):
tmp = []
for j in range(rows):
tmp.append(0)
self.matrix.append(tmp)
def GetColumns(self, columns):
for i in range(len(columns)):
self.matrix[i] = columns[i]
def GetOneColumn(slef, column , place):
place = place-1
self.matrix[place] = column
def GetInPut(self):
ColumnsArray = []
for i in range(self.columns):
ColumnsArray.append([])
for i in range(self.rows):
lineArray = list(map(int, input().split()))
for j in range(self.columns):
ColumnsArray[j].append(lineArray[j])
self.GetColumns(ColumnsArray)
def __repr__(self):
result = ""
for i in range(self.rows-1):
result += str(self.matrix[0][i])
for j in range(1,self.columns):
result += " " + str(self.matrix[j][i])
result += "\n"
for i in range(self.rows - 1, self.rows ):
result += str(self.matrix[0][i])
for j in range(1,self.columns):
result += " " + str(self.matrix[j][i])
return result