""" 使用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
原文:https://www.cnblogs.com/touch-prc/p/12907385.html