擅长:python、mysql、java
<p>换个角度想想:</p>
<p>金字塔中的每一行都是大约+1的“行”,并且在该行中完成的行数比所有行的总和相等或“更大”,即总块数。在</p>
<p>因此,如果您尝试使用此方法,您将得到以下代码:</p>
<pre><code>blocks = int(input("Enter number of blocks: "))
height = 0
by_row = 0
total = 0
for i in range(blocks):
if blocks <= total:
break
height += 1
by_row += 1
total += by_row
print(f"The height of the pyramid:{height}")
</code></pre>
<p>所以,这是你想要的跑步方式。在</p>