Canadian Computing Competition: 2008 Stage 1, Junior #4
Prefix notation is a non-conventional notation for writing arithmetic expressions. The standard way of writing arithmetic expressions, also known as infix notation, positions a binary operator between the operands, e.g.,
Similarly, in postfix notation, or reverse Polish notation, the operator is positioned after the operands. For example, postfix representation of the infix expression
Your task is to write a program that translates a prefix arithmetic expression into a postfix arithmetic expression.
Input Specification
Each line contains an arithmetic prefix expression. The operators are
Output Specification
Translate each expression into postfix notation and produce it on a separate line. The numbers and operators are separated by at least one space. The final
Sample Input
1
+ 1 2
- 2 2
+ 2 - 2 1
- - 3 + 2 1 9
0
Sample Output
1
1 2 +
2 2 -
2 2 1 - +
3 2 1 + - 9 -
Comments
I dont get why this problem is 7 points tbh
This problem is braindead
lol