方法的输入参数是一个字符串(内容是一个表达式,有多个加减运算),方法输出的是一个整型结果。
只能是一个函数
public int A(String ex){
int result=0;
.........
return result;
}
请问怎么把之这个函数补充完整
这个问题很简单,只有加减运算,没有运算优先级,不需要用到堆栈就可以。下面是代码:
public class App {运行结果:
大神能写一下栈的吗?万分感谢,要分的话,可以给您多加点
追答你把那个https的链接复制到浏览器里面,进去看一下,那个就是栈的一个实现。
大哥,我需要通过函数实现,我的想法是通过栈,但是忘了怎么做了。你说的eval 我没用过。我要的就是把上面的函数补充完整,谢谢
追答已经说过了
追问大神能帮帮忙把上面的函数补充完成,让我学习一下吗,万分感谢