我要打印以下图案:
1
2 2
3 3
4 4
3 3
2 2
1 # i want this
我正在python 3中打印此模式,但无法打印完全相同的模式
for row in range(1, 5):
for column in range(2):
print(row, end=" ")
print("\n")
for row in range(1, 5):
for column in range(1, row + 1):
print(column, end=' ')
print("") # this is my code
1 1
2 2
3 3
4 4
1
1 2
1 2 3
1 2 3 4 # this my output
答案 0 :(得分:0)
尝试一下。此代码缩进不正确。自己输入,然后查看输出。
const std::vector foo({1, 2, 3, 4});
foo.clear();
输出:
num = int(input("Enter the number"))
for i in range(1,num+1):
if i == 1:
print(i)
else:
print(i, i, sep=" ")
for i in range(num-1, 0, -1):
if i == 1:
print(i)
else:
print(i, i, sep=" ")