题目:
解题过程:
模式A:
num = int(input("(模式A)输入数字:"))
for i in range(num): for j in range(num): if j < i + 1: print(j + 1, end=" ") else: print("", end=" ") print()
模式B:
num = int(input("(模式B)输入数字:"))
for i in range(num): for j in range(num): if j < (num - i): if j != (num - i - 1): print(j + 1, end=" ") else: print(j + 1, end=" ") else: print(" ", end=" ") print()
模式C:
num = int(input("(模式C)输入数字:"))
for i in range(1, num + 1): for _ in range(num - i): print(" ", end=" ") for j in range(i, 0, -1): print(j, end=" ") print()
模式D:
num = int(input("(模式D)输入数字:"))
for i in range(num): for j in range(num): if j >= i: print(j - i + 1, end=" ") else: print(" ", end=" ") print()