编写一个 Python 程序,使用 for 循环打印右递减数字的平方图案。
rows = int(input("Enter Square of Right Decrement Numbers Rows = "))
print("====The Square of Right Decremented Numbers Pattern====")
for i in range(rows, 0, -1):
for j in range(rows, i - 1, -1):
print(j, end = ' ')
for k in range(rows - i + 1, rows):
print(i, end = ' ')
print()

此 Python 程序 使用 while 循环打印右递减数字的平方图案。
rows = int(input("Enter Square of Right Decrement Numbers Rows = "))
print("====The Square of Right Decremented Numbers Pattern====")
i = rows
while(i >= 1):
j = rows
while(j >= i):
print(j, end = ' ')
j = j - 1
k = rows - i + 1
while(k < rows):
print(i, end = ' ')
k = k + 1
print()
i = i - 1
Enter Square of Right Decrement Numbers Rows = 9
====The Square of Right Decremented Numbers Pattern====
9 9 9 9 9 9 9 9 9
9 8 8 8 8 8 8 8 8
9 8 7 7 7 7 7 7 7
9 8 7 6 6 6 6 6 6
9 8 7 6 5 5 5 5 5
9 8 7 6 5 4 4 4 4
9 8 7 6 5 4 3 3 3
9 8 7 6 5 4 3 2 2
9 8 7 6 5 4 3 2 1