INPUT FILE: kill.in
OUTPUT FILE: kill.out
Given an algebraic expression using the operator set {+ - * / ^ ( ) { }} format the expression according to the following rules:
You may implement only rules 1 through 4 for partial credit.
INPUT
On each line of the input file is an expression to be formatted.
OUTPUT
For each expression in the input file, first echo the expression and then output
the expression as it appears when formatted according to the above rules. Leave
a blank line between expressions.
Sample Input File
(1+2)/3+4 {1+20}/3+4 1^2^3+5 (1^2)^3+5 (1^2^3)+5 1/2/3+4
Output for Sample Input (Partially formatted on left, fully formatted on right)
(1+2)/3+4 (1 + 2) (1 + 2) ------- + 4 ------- + 4 3 3 {1+20}/3+4 1 + 20 1 + 20 ------ + 4 ------ + 4 3 3 1^2^3+5 3 3 2 2 1 + 5 1 + 5 (1^2)^3+5 3 3 ( 2) ( 2) + 5 (1 ) + 5 (1 ) (1^2^3)+5 ( 3) ( 3) ( 2 ) ( 2 ) + 5 (1 ) + 5 (1 ) 1/2/3+4 1 1 - - 2 2 - - + 4 3 + 4 3