编写一个Python程序,使用for循环打印右增量数字的平方。
rows = int(input("Enter Square of Right Increment Numbers Rows = "))
print("====The Square of Right Incremented Numbers Pattern====")
for i in range(1, rows + 1):
for j in range(1, rows - i + 1):
print(1, end = ' ')
for k in range(1, i + 1):
print(i, end = ' ')
print()
这个Python程序使用一个while循环从右边打印出增量数字的正方形图案。
rows = int(input("Enter Square of Right Increment Numbers Rows = " ))
print("==== 右边增量数字的平方图案====") i = 1
while(i <= rows): j = 1 while(j <= rows - i): print(1, end = ' ') j = j + 1 k = 1 while(k <= i): print(i, end = ' ') k = k + 1 print() i = i + 1
Enter Square of Right Increment Numbers Rows = 9
====The Square of Right Incremented Numbers Pattern====
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 2 2
1 1 1 1 1 1 3 3 3
1 1 1 1 1 4 4 4 4
1 1 1 1 5 5 5 5 5
1 1 1 6 6 6 6 6 6
1 1 7 7 7 7 7 7 7
1 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9