Skip to content · ⁨본문 바로가기⁩

RPN calculator · ⁨RPN 계산기⁩

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 계산기

역폴란드 표기법에서는 연산자가 두 숫자 뒤에 옵니다: 2 3 +은 2 + 3을 의미하며, 2 3 4 * +은 2 + (3 * 4) = 14을 의미합니다. 괄호는 필요 없습니다.

스택(목록)을 사용합니다. 토큰을 왼쪽에서 오른쪽으로 읽습니다: 숫자는 밀고(push), 연산자를 만나면 상단 두 개를 빼내 combining(순서 주의 — 먼저 뺀 값이 우변임), 결과를 밀고합니다. 답은 택 위에 남은 것입니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP