[英]How can i do a java iterator to print out an array
我不太确定迭代器是如何工作的,或者如何在我的 main 中调用它们,我该怎么做???
不清楚你在问什么。 但是,如果您的意图是使用递归将诸如“5 * 3 + 2”之类的表达式转换为表达式树,那么这是伪代码中的近似算法(忽略任何先例,因为您没有问过这个问题):
function getExpressionTree(expr): Node
if (expression has operator)
create new node with operator
node's left operand = getExpressionTree(substring before operator)
node's right operand = getExpressionTree(substring after operator)
return node
else
return constant node from expression
您发布的代码中有很多问题,但鉴于您刚刚寻求一般帮助,我希望上面的算法可以帮助您入门。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.