443
社区成员
发帖
与我相关
我的任务
分享
# 输入一个整数n,1<=n<=10,输出一个n层的特定三角形,如n=5,则三角形为:
# 1 6 10 13 15
# 2 7 11 14
# 3 8 12
# 4 9
# 5
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# 2023-02-27
index=1
list=[]
n=int(input('请输入一个整数:'))
for item in range(n):
m=n-item
if m>=0:
strValue=''
tempValue=0
for item2 in range(m):
if item2==0:
tempValue=item+1
strValue+=str(tempValue)
else:
tempValue+=n-item2+1
strValue+=' '+str(tempValue)
list.append(strValue)
for item in list:
print(f'{item}')