Anonymous user
Parsing/RPN to infix conversion: Difference between revisions
→{{header|Java}}: move ops field
(→{{header|Java}}: move ops field) |
|||
Line 1,091:
=={{header|Java}}==
{{works with|Java|7}}
<lang java>
public static void main(String[] args) {
Line 1,104 ⟶ 1,102:
}
static String postfixToInfix(final String postfix) {
final String ops = "-+/*^";▼
class Expression {
▲ final static String ops = "-+/*^";
String op, ex;
int prec = 3;
Line 1,131 ⟶ 1,130:
for (String token : postfix.split("\\s")) {
char c = token.charAt(0);
int idx = Expression.ops.indexOf(c);
if (idx != -1 && token.length() == 1) {
|