首页 > 其他 > 详细

使用while实现打印直角三角形

时间:2020-05-17 23:01:53      阅读:78      评论:0      收藏:0      [点我收藏+]
"""
    使用while实现打印直角三角形
    要求输入一个整数表示三角形的宽和高,打印出如下的三种直角三角形
    1)
       *
      **
     ***
    ****
    2)
    ****
    ***
    **
    *
    3)
    ****
     ***
      **
       *
"""
high_bottom = int(input(请输入直角三角形的高(高和底相等的直角三角形):))
count_1 = 1 # 计数器
count_2 = 0 # 计数器
count_3 = 0 # 计数器
reciprocal = high_bottom
#第一个
print(--------第一个三角形--------)
while count_1 <= high_bottom:
    space = high_bottom -count_1
    print(  * space +* * count_1)
    count_1 +=1
#第二个
print(--------第二个三角形--------)
while count_2 < high_bottom:
    asterisk = high_bottom -count_2
    print(* * asterisk +   * count_2)
    count_2 +=1
#第三个
print(--------第三个三角形--------)
while count_3 < high_bottom:
    asterisk = high_bottom -count_3
    print(  * count_3 + * * asterisk)
    count_3 +=1

 

使用while实现打印直角三角形

原文:https://www.cnblogs.com/touch-prc/p/12907385.html

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