1 / 11

stA

中置記法( IN ) → 後置記法( RPN ) による演算処理 例)  1 + 2 * 3 - 4 ↓ 1 2 3 * + 4 -. 1 個 ずつ tmp に取り出す ( st B の中は RPN の逆順) ・ 数字の場合 : st A に push ・ 演算子 の 場合 : 演算処理. tmp. 1. 2. 3. d [0]. *. stA. st B. +. 4. d[1]. -. 中置記法( IN ) → 後置記法( RPN ) による演算処理 例)  1 + 2 * 3 - 4 ↓ 1 2 3 * + 4 -. tmp. 1.

camila
Télécharger la présentation

stA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 1 2 3 * + 4 - 1個ずつtmpに取り出す (stBの中はRPNの逆順) ・ 数字の場合:stAにpush ・ 演算子の場合: 演算処理 tmp 1 2 3 d[0] * stA stB + 4 d[1] -

  2. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 1 2 3 * + 4 - tmp 1 2 3 d[0] * stA stB + 4 d[1] 1 -

  3. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 12 3 * + 4 - tmp 2 3 d[0] * stA stB + 2 4 d[1] 1 -

  4. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 123 * + 4 - tmp 3 d[0] * stA stB 3 + 2 4 d[1] 1 -

  5. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 12 3 * + 4 - tmp * 2 d[0] stA stB 3 + 3 2 4 d[1] 1 -

  6. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 16+ 4 - tmp d[0]*d[1]=2*3=6 をstAにpush * 2 d[0] stA stB + 3 6 4 d[1] 1 -

  7. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 1 6 + 4 - tmp + 2 1 d[0] stA stB 3 6 6 4 d[1] 1 -

  8. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 7 4 - tmp d[0]+d[1]=1+6=7 をstAにpush + 1 d[0] stA stB 6 4 d[1] 7 -

  9. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 74 - tmp 4 1 d[0] stA stB 6 4 d[1] 7 -

  10. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 7 4- tmp - 7 1 d[0] stA stB 6 4 4 d[1] 7

  11. 中置記法(IN) → 後置記法(RPN)による演算処理中置記法(IN) → 後置記法(RPN)による演算処理 例) 1+2*3-4 ↓ 3 tmp d[0]-d[1]=7-4=3 をstAにpush - 7 d[0] stA stB 4 d[1] 3

More Related