What is wrong in my code, please help
#include <bits/stdc++.h>
using namespace std;
int Precedence(char c)
{
if(c == '+' || c == '-')
{
return(1);
}
else if(c == '*' || c == '/')
{
return(2);
}
else if(c == '^')
{
return(3);
}
return(0);
}
int isOperand(char c)
{
if(c == '+' || c == '-' || c == '(' || c == ')' || c == '*' || c == '/' || c == '^')
{
return(0);
}
else
{
return(1);
}
}
void inTopost(string s,int l)
{
stack<char> st;
int i = 0;
while(i < l)
{
if(isOperand(s[i]))
{
cout<<s[i];
i++;
}
else
{
if(st.empty() || s[i] == '(')
{
st.push(s[i]);
i++;
}
else
{
if(s[i] == ')')
{
while(st.top() != '(' && !st.empty())
{
cout<<st.top();
st.pop();
}
st.pop();
i++;
}
else if(Precedence(s[i]) > Precedence(st.top()))
{
st.push(s[i]);
i++;
}
else
{
while(Precedence(s[i]) <= Precedence(st.top()) && !st.empty())
{
cout<<st.top();
st.pop();
}
st.push(s[i]);
i++;
}
}
}
}
while(!st.empty())
{
cout<<st.top();
st.pop();
}
cout<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
int t;
cin>>t;
while(t--)
{
int len;
cin>>len;
string s;
cin>>s;
inTopost(s,len);
}
return 0;
}