我的目标是从标准输入接收一个方程,将其存储在一个数组中以供以后使用/重新打印,然后输出一行打印整个方程和答案,就像这样:
输入:2+3=
输出:2 + 3 = 5
由于 Ada 无法拥有动态字符串等,我对如何执行此操作感到非常困惑。
这是我在伪代码中的一个粗略想法..
Until_loop:
loop
get(INT_VAR);
--store the int in the array?
get(OPERATOR_VAR);
--store the operator in the following index of that array? and
--repeat until we hit the equal sign, signaling end of the equation
get(CHECK_FOR_EQUALSIGN);
exit Until_loop when CHECK_FOR_EQUALSIGN = "=";
end loop Until_loop;
--now that the array is filled up with the equation, go through it and do the math
--AND print out the equation itself with the answer
我猜数组应该是这样的:
[2][+][5][=][7]
我也是Ada的初学者,所以掌握起来更加困难,我对Java非常擅长,但是我不习惯强类型的语法。请询问您是否需要更多信息。