#C3098. Infix to Postfix Expression Converter
Infix to Postfix Expression Converter
Infix to Postfix Expression Converter
You are given an arithmetic expression in infix notation which may include positive integers, the operators +, -, *, /, and parentheses ( )
. Your task is to convert the given expression into its equivalent postfix expression (also known as Reverse Polish Notation).
The conversion should follow the standard operator precedence rules. In particular, the precedence is given by \( +, - \) at level 1 and \( *, / \) at level 2. Parentheses can be used to override these preferences.
Example:
Input: ((2 + 3) * 5) - (8 / (4 + 2))
Output: 2 3 + 5 * 8 4 2 + / -
inputFormat
The input consists of a single line that contains an arithmetic expression in infix notation. The tokens (numbers, operators, and parentheses) are separated by spaces.
outputFormat
Output a single line representing the equivalent postfix expression with tokens separated by single spaces.
## sample2 + 3
2 3 +