Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Switch(char of string)
- case operand -> append to postfix string
- case '(' -> push on stack
- case operator -> if empty stack, push on stack. Otherwise pop all operators of greater or equal precedence until')' or an operator of lower precedence is reached or stack becomes empty and append them to postfix string. Push the operator on stack.
- case ')' -> pop operators off the stack, appending them to postfix string. When you encounter a '(', pop it off.
- case End of infix string -> pop any remaining operators off the stack and append them to postfix string.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement