Help needed in SPOJ NOP-(Transform the expression)

Here is my code… i don’t know where it fails in the hidden test cases.
/*
#include<bits/stdc++.h>
using namespace std;

int pre(char a){
if(a==’^’)
return 3;
else if(a==’|’ || a==’*’)
return 2;
else if(a==’+’ || a==’-’)
return 1;
else return -1;

}
bool op(char a){

if(a==’^’ || a==’|’ || a==’*’ || a==’+’ || a==’-’)
return true;
else return false;

}
string infix_to_postfix(string e){

int i,j,k;
string s = "";
stack<char> st;

for(i=0; i<e.length(); i++){

    if(e[i]>='a' && e[i]<='z')
        s += e[i];
    else if(e[i]=='(')
        st.push(e[i]);
    else if(op(e[i]) == true){


            //ll t = st.top();
            while(pre(st.top()) >= pre(e[i])){
                s += st.top();
                st.pop();
            }
            st.push(e[i]);
        }


    else if(e[i]==')'){
        while(st.top()!='('){
                s += st.top();
                st.pop();
        }
        st.pop(); // remove '('
    }

}
while(!st.empty()){
        s += st.top();
        st.pop();

}

return s;

}
int main()
{
int t;
cin>>t;
while(t–){
string exp;

cin>>exp;


cout<<infix_to_postfix(exp)<<endl;

}

}

*/