看板 Grad-ProbAsk 關於我們 聯絡資訊
http://ppt.cc/MSFh 第三題的D選項對嗎? 我看分類題庫上D是對的 步驟是 1. push "7" 2. push "2" 3. pop "2" , pop "7" 2 + 7 = 9 , push "9" 4. push "5" 5. push "8" 6. push "4" 7. pop "4" , pop "8" , 8 / 4 = 2 , push "2" 8. pop "2" , pop "5" , 5 - 2 = 3 , push "3" 9. pop "3" , pop "9" , 9 * 3 = 27 , push "27" ---------答案就寫到這------ 所以是 9 個 push , 8 個 pop 但是最後不用把 27 從 stack 裡在pop出來嗎? 我看 postfix evaluation 的 algo 最後都會在把pop stack 其值為結果值 這樣的話就變 9 個 pop 所以請教大家這題的D選項究竟是 8 個 pop 還是算 9 個 pop 呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.25.118.139
wheels:我覺得應該是9個,模擬考時有一題類似但為了避免這種誤解, 01/31 03:32
wheels:所以改成"when we scanned over this postfix when we 01/31 03:33
wheels:evaluating this postfix using stack" 01/31 03:33
wheels:如果是者種問法才是8個。 01/31 03:33
wheels: 這 01/31 03:34
n60119:瞭解了 回答超詳細的 感謝~ 02/01 00:50