p = [[(5,7),(2,4)],[(5,1),(2,8)],[(5,4),(3,2)]]
print('原資料')
for i in p:
print(i)
print('一維化')
t = []
for i in p:
for j in i:
for k in j:
t.append(k)
print(t)
print('列反序')
for i in p[::-1]:
print(i)
print('行反序')
for i in p:
t = []
for j in i[::-1]:
t.append(j)
print(t)
print('個別資料反序')
for i in p:
t = []
for j in i:
t.append([j[1],j[0]])
print(t)
# Output:
# 原資料
# [(5, 7), (2, 4)]
# [(5, 1), (2, 8)]
# [(5, 4), (3, 2)]
# 一維化
# [5, 7, 2, 4, 5, 1, 2, 8, 5, 4, 3, 2]
# 列反序
# [(5, 4), (3, 2)]
# [(5, 1), (2, 8)]
# [(5, 7), (2, 4)]
# 行反序
# [(2, 4), (5, 7)]
# [(2, 8), (5, 1)]
# [(3, 2), (5, 4)]
# 個別資料反序
# [[7, 5], [4, 2]]
# [[1, 5], [8, 2]]
# [[4, 5], [2, 3]]
沒有留言:
張貼留言