3 2 + 4 3 * +It's enough to take en empty LIFO stack, go through it and:
1 When we see a number push it on stack.
2. Seeing operand, pop stack twice, perform the operation and push result.
3. When done pop stack - this is result!
Parsing is not such easy, but is explained in details, for example, here.
Code on github.
Whole Series.
Thank you!
No comments:
Post a Comment