Infix to Postfix Conversion
Convert an infix expression to postfix notation using a stack.
Input format
A single line with an infix expression using single-letter operands (a-z), the operators + - * / ^, and parentheses. No spaces.
Output format
Print the equivalent postfix expression (no spaces). ^ is right-associative with the highest precedence; * / bind tighter than + -.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
a+b*cExpected output
abc*+Example 2
Input
(a+b)*cExpected output
ab+c*