문제1535--Infix-Postfix Conversion

1535: Infix-Postfix Conversion

실행시간 제한: 10 Sec  메모리사용 제한: 512 MB  Special Judge
제출: 3946  통과: 1031
[제출] [채점기록] [묻고답하기]

문제 설명

Given an infix expression, convert that into a postfix expression. The operators are "+, -, *, /" and the operands are non-negative integers less than or equal to 108. If the expression is illegal then print out 'syntax error'(without quotation mark). The number of operands in the expression is at most 1000.

입력 설명

Input consists server test cases.

A test case consists combination of the operators, integers, and  brackets. Last character of the test case is '\n'.

If a test case contains the word 'end' then you should ignore the case and finish your program.

 

출력 설명

Output the result of conversion(infix-to- postfix) for each test case. 

 

입력 예시 Copy

5 + 65 * 2
7 * ((14-12)*20)
21 + (10 / 3)
5 * (24 + 6) | 155
11+26/3
1237 * 34 + 26 -
1 + 1 + 1 + 1 + 1 
end

출력 예시 Copy

5 65 2 * + 
7 14 12 - 20 * * 
21 10 3 / + 
syntax error
11 26 3 / + 
syntax error
1 1 + 1 + 1 + 1 + 

출처/분류