The Stack Computer is loaded with boxes from a conveyer belt. The boxes are marked with a Number or an Operator (+, -, * or /).
堆栈计算机从传送带上装载着标有数字或运算符(加号、减号、乘号或除号)的盒子。
The computer is loaded until the top box is a box marked with an operator. This operator is then used on the two boxes below it. The three boxes are then fused into one single box and marked with the outcome of the calculation.
计算机一直加载,直到最上面的盒子是一个标有运算符的盒子。然后,该运算符用于其下方的两个盒子。这三个盒子随后融合成一个盒子,并标上计算结果。
In the Stack Computer, calculations are entered in a different way to a normal calculator.
在堆栈计算机中,输入计算的方式与普通计算器不同。
Try these examples: 试试这些例子:
Enter your solution in the input box, and use the buttons to try it out on the Stack Computer.
在输入框中输入您的解决方案,然后使用按钮在堆栈计算机上进行测试。
- 2+3 must be entered as 2 3 +
- 10-2 must be entered as 10 2 -
- 5*2+3 must be entered as 5 2 * 3 +
- 5+2*3 must be entered as 5 2 3 * +
- (8-2)*(3+4) must be entered as 8 2 - 3 4 + *
Question: 问题:
How should the following computation be entered: 4*(8+3)-2?
以下计算应如何输入:4*(8 3)-2?
![]()

Explanation 解释
The correct answer is 4 8 3 + * 2 -.
正确答案是 4 8 3 + * 2 -。
However, the following answers are also acceptable as they all produce the correct output.
然而,以下答案也是可以接受的,因为它们都能产生正确的输出。
- 4 3 8 + * 2 -
- 8 3 + 4 * 2 -
- 3 8 + 4 * 2 -
These inputs all lead to the same result, even though the order of the operators and operations are not the same as intended in the given expression.
这些输入都会得出相同的结果,尽管运算符和运算的顺序与给定表达式中预期的顺序不同。
From left to right, we first have 4*(8+3), so we need 4 and the result of 8+3 on the stack. We achieve that by writing:
从左到右,我们首先有 4*(8 3),所以我们需要 4 和 8 3 的结果在栈上。我们通过写入以下内容来实现:
4 8 3 +
We then have 4 and 11 on the stack, so we add a * to multiply the two numbers. We now have 44 on the stack, we add a 2 and a – for the final subtraction.
此时栈上有 4 和 11,所以我们添加一个 * 来将这两个数字相乘。现在栈上有 44,我们再添加一个 2 和一个 - 用于最后的减法运算。
Bebras新赛季备赛已开启,扫码领取Bebras真题资料⇓
欢迎咨询【Bebras专业辅导课程】


(Bebras每日一练部分展示)
