How can I write this statement from infix to postfix?
How can I write thi开发者_如何学Cs statement:
9-3/(1+2)
... from infix to postfix?
9-3/(1+2)
First would be (1+2) since it has the highest order of operation.
-> 1 2 +
Then 3 divided by the result...
-> 3 1 2 + /
Then 9 minus the result....
-> 9 3 1 2 + / -
9 3 1 2 + / - (and more stuff to make 15 characters)
You can use the Shunting-yard algorithm to convert from infix to postfix notation.
精彩评论