开发者

How can I write this statement from infix to postfix?

开发者 https://www.devze.com 2022-12-11 10:13 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消