retorlin 2022-10-11 10:38:36

python输出“*”号三角形

#正三角形
for i in range(1,10):
    for j in range(9-i):
        print("  ",end="")
    for k in range(1,i*2):
        print("* ",end="")
    print("")
#倒三角形
for i in range(1,10):
    for j in range(1,i*2):
        print(" ",end="")
    for k in range((10-i)*2-1):
        print("* ",end="")
    print("")

评论

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-05 19:03
浙ICP备14020137号-1 $bản đồ khách truy cập$