编辑代码

#递归算法实现:
# def recursive_print(n):
#     if n > 0:
#         recursive_print(n-1)
#         print(*[n]*n)

# def main_recursive():
#     n = 5
#     recursive_print(n)

# if __name__ == "__main__":
#     main_recursive()

#非递归算法实现:
def non_recursive_print(n):
    for i in range(1, n+1):
        print(*[i]*i)

def main_non_recursive():
    n = 5
    non_recursive_print(n)

if __name__ == "__main__":
    main_non_recursive()