Company: Canonical_10thjuly
Difficulty: medium
Calculator An arithmetic expression can be written in prefix notation , where every operator is written before its two operands. Prefix notation needs no parentheses, because the position of each operator already says exactly which operands it applies to: Traditional notation Prefix notation 3 + 4 + 3 4 3 - (4 * 5) - 3 * 4 5 (3 + 4) * 5 * + 3 4 5 (3 - 4) / (5 + 2) / - 3 4 + 5 2 Read one such expression and print its value. Input Format The whole of standard input is the expression. Split it into tokens on whitespace (spaces, tabs and newlines); the amount and kind of whitespace carries no meaning, and leading and trailing whitespace is allowed. Each token is either an operator — a token exactly one character long, being one of + , - , * , / ; or a number , matching this grammar exactly ( D stands for one digit 0 - 9 ): [+|-] ( D...D [ . [D...D] ] | . D...D ) [ (e|E) [+|-] D...D ] So 3 , -2.5 , .5 , 5. , +3 , 1e3 and 2.5E-4 are numbers, while 0x10 , 1_0 , 1d , nan , Infinity , 1e , --3