Class 1 HW D (Fall 2024 102PC)

Why does the problem say that my code is incorrect?
Question Description: Our goal in this question is to print out a number triangle.
Start with the integer 1. The ith line contains i integers, and every number in the triangle takes up 4 positions (aligned to the right).
(In C, you can use “%4d” to format the output, which takes up 4 positions and aligns to the right).

Code:
n = int(input())
c = 1
for i in range(1, n + 1):
for j in range(1,i+1):
print(“%4d”%c, end=" ")
c += 1
print()

2 个赞

Who are you?

1 个赞

why did you use Python???

1 个赞

You must save this problem with C++.

2 个赞

Where do you live in?
I live in Wuhan,Hubei,China.

2 个赞

Why don’t you ask this in X-Camp?

1 个赞

大家英语好棒呀

1 个赞

悄悄告诉你,我是我们班英语课代表 :sweat_smile:

2 个赞

wow

1 个赞