1990 ACM East Central Regional Programming Contest
Problem 6: Equation
| Source file: |
prob6.c or prob6.pas |
| Input file: |
prob6.in |
| Output file: |
prob6.out |
The Problem
Write a program that changes an infix expresssion to a postfix expression
according to the following specifications.
- The infix expression to be converted is in the input file name
PROB6.IN in the format of one character per line, with a maximum of
50 lines in the file. For example, (3+2)*5 would be in the form:
(
3
+
2
)
*
5
- The file PROB6.IN contains only one infix expression. There are no
blank lines.
- The program will only be designed to handle the binary operators +, -,
*, /.
- The operands will be one digit numerals.
- The operators * and / have the highest priority. The operators + and
- have the lowest priority. Operators at the same precedence level
associate from left to right. Parentheses act as grouping symbols that
over-ride the operator priorities.
- The output file PROB6.OUT will have the postfix expression all on
one line. For example, if PROB6.IN has the contents shown in
specification I, the PROB6.OUT would contain the one line:
32+5*
- The input will be an expression with valid syntax.