多组输入,一个整数(2~20),表示输出的行数,也表示组成反斜线的“*”的数量。
针对每行输入,输出用“*”组成的反斜线。
4
* * * *
5
* * * * *
while True: try: n=int(input()) for i in range(0,n): print(' '*i+'*') except: break
while True: try: n = int(input()) for i in range(0, n ): temp = " " * i + "*" print(f"{temp:<{n**2+2}}") # ^居中,>居右,<居左对齐 except Exception as e: break
while True: try: a = int(input()) for i in range(1, a + 1): print(" "*(i-1)+"*") except: break
while True: try: n=int(input()) for i in range(n): print(' '*i+'*') except: break
while True: try: n = int(input()) for i in range(n): print(' '*i+'*') except: break
while True: try: num = int(input()) for i in range(1,num + 1): print(" "*(i-1)+"*") except: break
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题