Infix to Postfix
Submissions: 14030   Accuracy:

48.37%

  Difficulty: Medium   Marks: 4

Given an infix expression in the form of a string str. Conver this infix expression to postfix expression.

  • Infix expression: The expression of the form a op b. When an operator is in-between every pair of operands.
  • Postfix expression: The expression of the form a b op. When an operator is followed for every pair of operands.

Input:
The first line of input contains an integer T denoting the number of test cases. The next T lines contains an infix expression.The expression contains all characters and ^,*,/,+,-.

Output:
For each testcase, in a new line, output the infix expression to postfix expression.

Constraints:
1 <= T <= 100
1 <= length of str <= 103

Example:
Input:

2
a+b*(c^d-e)^(f+g*h)-i
A*(B+C)/D

Output:
abcd^e-fgh*+^*+i-
ABC+*D/

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.