|
Problem:
The following code is an implementation of the stack operation. Complete the program to convert postfix to infix using the given C++ sample code.
Hand in:
1) A Single zipped file which contains Source code and output:
(Lab8.cpp, Lab8.h, Lab8A.h, Lab8.doc (Capture your screen shot- Don’t type ))
2) Upload two files to the Black board.
# When you upload files to the black board, those files should be compressed to one single file as attachment.( only five chances to upload)
Input
A B C * + D E / F * -
Output
(A+(B*C))-((D/E)*F))
Algorithm of Postfix to infix
1. Push post fix notation to the PostfixStack reverse order
( eg. push - * F / E D + * C B A)
2. while there are no data at PostfixStack
3. read one symbol from the PostfixStack
4. if the symbol is an operand
5. push it into the InfixStack
6. else
7. pop the top 2 values from the InfixStack
8. put the operator between two operand
9. Encapsulate the resulted string with parenthesis
10. if there is only one value in the stack
That value in the stack is the desired Infix notation
|