conversion from infix to prefix

后端 未结 14 1306
有刺的猬
有刺的猬 2020-12-09 10:24

I am preparing for an exam where i couldn\'t understand the convertion of infix notation to polish notation for the below expression:

(a–b)/c*(d + e – f / g)         


        
14条回答
  •  独厮守ぢ
    2020-12-09 10:40

    (a–b)/c*(d + e – f / g)

    Prefix notation (reverse polish has the operator last, it is unclear which one you meant, but the principle will be exactly the same):

    1. (/ f g)
    2. (+ d e)
    3. (- (+ d e) (/ f g))
    4. (- a b)
    5. (/ (- a b) c)
    6. (* (/ (- a b) c) (- (+ d e) (/ f g)))

提交回复
热议问题