Home > Back-end >  Calculator and BNF type Java addition, subtraction, multiplication, and division
Calculator and BNF type Java addition, subtraction, multiplication, and division

Time:10-01

# # stack calculator
In the study of BNF type of input characters into the form of a calculator, such as


Let x=1; The result is 1
(let a=2) + 3 * a - 5; The results of 3
(let x=(let y=(let z=1))) + x + y + z; The results of 4
1 + (let x=1) + (let y=2) + (1 + x) * (1 + y) - (let x=y) - (let y=1) - x; The results of 5
(let a=(let a=(let a=(let a=2) + a + a) + a) - 9; The results of 7
(let y=3) ^ (let x=2). The results of 9


Think through the stack and a hashmap to solve, the hashmap x y and a key/value pair, but I don't know how to set x y z value picked out and updated, beg god taught!!!!!!