Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

RPN calculator

English

RPN calculator

In Reverse Polish Notation the operator comes after its two numbers: 2 3 + means 2 + 3, and 2 3 4 * + means 2 + (3 * 4) = 14. No brackets needed.

Use a stack (a list). Read tokens left to right: push numbers; when you hit an operator, pop the top two, combine them (mind the order — the first value popped is the right-hand side), and push the result. The answer is what's left on top.

ไทย

เครื่องคิดเลข RPN

ใน Reverse Polish Notation operator มา หลัง ตัวเลขสองตัว: 2 3 + หมายความว่า 2 + 3, และ 2 3 4 * + หมายความว่า 2 + (3 * 4) = 14. ไม่ต้องใช้วงเล็บ

ใช้ stack (a list). อ่าน tokens จากซ้ายไปขวา: push numbers; เมื่อเจอ operator, pop สองค่าบนสุด, ผสมผสาน (ระวังลำดับ — ค่าแรกที่ถูก pop คือด้านขวา), และ push ผลลัพธ์. คำตอบคือสิ่งที่เหลืออยู่บนยอด

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP