include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
//操作符优先级
int priority(char op){
if(op == ‘+’ || op == ‘-‘)
return 1;
else if(op == ‘*’ || op == ‘/’)
return 2;
else return 0;
}
string infixToPostfix(string infix){
stack[HTML_REMOVED] st;
string postfix;
for(auto c : infix){
if(c == ' ') continue;
if(c >= 'A' && C <= 'Z' || c >='a' && c <= 'z')
postfix += c;
else if(c == '(') st.push(c);
else if(c == ')'){
while(!st.empty() && st.top() != '('){
postfix += st.top();
st.pop();
}
if(st.empty()) return "Invalid Expression";
st.pop()
}
else{//运算符的情况
while(!st.empty() && priority(c) <= priority(st.top())){
postfix += st.top();
st.pop();
}
st.push(c);
}
}
while(!st.empty()){
if(st.top() == '(') return "Invalid Expression";
postfix += st.top();
st.pop()
}
}
int main() {
string infix;
cin >> infix;
string postfix = infixToPostfix(infix);
cout << postfix << endl;
return 0;
}