#Python 列印矩陣,內容為c+r
def compute(lt):
for r in range(rows):
for c in range(cols):
print(“%3d”%lt[r][c],end=””)
print()
#跟內層的迴圈同縮排
rows=3
cols=3
lt=[]
for r in range(rows):
lt.append([])
for c in range(cols):
lt[r].append(c+r)
compute(lt)
近期留言