更新时间:2023-11-24 08:35:46
我会用 int
s。
从底部一行开始,比较每个被分配的数字对。取较大的一个,并将其添加到对上方的数字:
Start at the bottom row and compare each adjanced pair of numbers. Take the bigger one and add it to the number above the pair:
5 3 13 3
\
7 8 6 becomes 7 8 6
^ ^
13 3 13 11
/
Next iteration 7 8 6 becomes 7 8 6 etc.
^ ^
以你的方式到顶部,当你完成后,将包含最大的金额。
Work your way to the top and when you're done, the tip of the triangle will contain the largest sum.