#P1449. Postfix Expression Evaluation
Postfix Expression Evaluation
Postfix Expression Evaluation
This problem requires you to evaluate a postfix expression without parentheses. In a postfix expression, each operator follows its two operands and the evaluation is performed strictly from left to right, without taking operator precedence into account.
The expression contains only the operators \(+, -, \*, /\). It is guaranteed that the divisor is never 0 when performing \(/\) operations. In particular, the result of a division must truncate toward 0 (i.e. the same as C++'s `/` operator).
In the given expression, a number is terminated by a .
(dot) and the end of the expression is indicated by a @
symbol. For example, the infix expression \(3 \times (5-2) + 7\) corresponds to the postfix expression 3.5.2.-*7.+@
.
inputFormat
The input consists of a single line which is the postfix expression string ending with an '@' character. Each operand is terminated by a '.' character and the operators are one of +, -, *, or /.
outputFormat
Output a single integer which is the result of evaluating the postfix expression.
sample
3.5.2.-*7.+@
16