如何用python输出如下矩阵?
10*10的矩阵,按顺序输出1~100的上三角[[12345678910][0121314151617181920][002324252627282930][000343...
10*10的矩阵,按顺序输出1~100的上三角
[[ 1 2 3 4 5 6 7 8 9 10]
[ 0 12 13 14 15 16 17 18 19 20]
[ 0 0 23 24 25 26 27 28 29 30]
[ 0 0 0 34 35 36 37 38 39 40]
[ 0 0 0 0 45 46 47 48 49 50]
[ 0 0 0 0 0 56 57 58 59 60]
[ 0 0 0 0 0 0 67 68 69 70]
[ 0 0 0 0 0 0 0 78 79 80]
[ 0 0 0 0 0 0 0 0 89 90]
[ 0 0 0 0 0 0 0 0 0 100]] 展开
[[ 1 2 3 4 5 6 7 8 9 10]
[ 0 12 13 14 15 16 17 18 19 20]
[ 0 0 23 24 25 26 27 28 29 30]
[ 0 0 0 34 35 36 37 38 39 40]
[ 0 0 0 0 45 46 47 48 49 50]
[ 0 0 0 0 0 56 57 58 59 60]
[ 0 0 0 0 0 0 67 68 69 70]
[ 0 0 0 0 0 0 0 78 79 80]
[ 0 0 0 0 0 0 0 0 89 90]
[ 0 0 0 0 0 0 0 0 0 100]] 展开
展开全部
K = 1
lst = [ ]
tmp = [ ]
for i in range(10, 历吵110, 10):
bo = (K - 1) 渗改// 10
if bo > 0:
for j in range(bo):
tmp.append(0)
肢喊侍for x in range(K + bo, i + 1):
tmp.append(x)
lst.append(tmp)
K += 10
tmp = [ ]
print(lst)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询