Converting equation from infix to postfix using stack
Expand Post »
I am working on a home work assignment which is:
"Write a program that will allow the user to enter an infix expression terminated by '=' your program will convert to Postfix notation"
enter 3+7-6/2*8+7=
prints 3 7 + 6 2 / 8 * - 7 +
I have written the code below to complete this useing single digits, but I want to allow the user to put in any number and have it do the same
ie 37+47/12 prints 37 47 + 12/
This is not part of the assignment, but I have the next two week to fiddle with it.
Any suggestion? I am lost at the moment.
Re: Converting equation from infix to postfix using stack
The first thing I would suggest is you parse the expression from a string (and not user input), and return an expression list (not void, and not in a global).
Re: Converting equation from infix to postfix using stack
I would also suggest better formatting. See this and pay particular attention to the Indentation section. As it is your code is very difficult to follow.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.