首页 > 其他 > 详细

使用 * 输出直角三角形

时间:2018-03-11 13:40:52      阅读:239      评论:0      收藏:0      [点我收藏+]

正方向

height = int(input("please input height: "))

tmp = 1
while tmp <= height:
    width = tmp
    while width > 0:
        print("*", end="")
        width -= 1
    print("")
    tmp += 1

测试结果:

技术分享图片

 

反方向:

height = int(input("please input height: "))

while height > 0:
    tmp = height
    while tmp > 0:
        print("*",end="")
        tmp -= 1
    print()
    height -= 1

测试结果:

技术分享图片

使用 * 输出直角三角形

原文:https://www.cnblogs.com/klvchen/p/8543379.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!