# coding:utf8
__author__ = 'bluesli'
'''
[0, 1, 2, 3]
[0, 1, 2, 3]
[0, 1, 2, 3]
[0, 1, 2, 3]
旋轉90度后是這樣的:
[0, 0, 0, 0]
[1, 1, 1, 1]
[2, 2, 2, 2]
[3, 3, 3, 3]
實際上就是沿着對角線交換數字:但是已經交換過了的就不能再交換,所以必須讓內層循環從i開始;
'''
def rotation(two_demensional_array=[]):
for i in range(len(two_demensional_array)):
for j in range(i,len(two_demensional_array)):
temp = two_demensional_array[i][j]
two_demensional_array[i][j] = two_demensional_array[j][i]
two_demensional_array[j][i] = temp
def show(two_demensional_array=[]):
for data in two_demensional_array:
print(data)
if __name__ == '__main__':
datas = [[col for col in range(4)] for row in range(4)]
show(datas)
rotation(datas)
show(datas)
'''
enumerate() 函數用於將一個可遍歷的數據對象
(如列表、元組或字符串)組合為一個索引序列,同時列出數據和數據下標
,一般用在 for 循環當中。
'''
# for r_index,element in enumerate(datas):
# print(r_index,element)