我正在尝试编写一个反向波兰计算器,但我不想为输入的每个算术运算符编写开关。是否可以输入算术运算符并在语言本身内部使用它? 例如,程序可以提示用户输入算术运算符 for:, a = b [whatever operator here] c; 并且某些变量将存储该运算符。假设是+,我们得到: a = b + c;
a = b [whatever operator here] c;
+
a = b + c;
这是可能的还是我应该把它吸收并为操作员编写开关?
c arithmetic-expressions postfix-notation
arithmetic-expressions ×1
c ×1
postfix-notation ×1