include[HTML_REMOVED]
using namespace std;
stack[HTML_REMOVED] num;
stack[HTML_REMOVED] op;
void caculate()
{
int a=num.top();
num.pop();
int c=num.top();
num.pop();
char b=op.top();
op.pop();
int sum=0;
if(b==’+’)
{
sum=a+c;
}
else if(b==’-‘)
{
sum=a-c;
}
else if(b==’’)
{
sum=ac;
}
else if(b==’/’)
{
sum=c/a;
}
num.push(sum);
return ;
}
int main()
{
unordered_map<char,int> mp{{'+',1},{'-',1},{'*',2},{'/',2}};
string str;
cin>>str;
for(int i=0;i<str.size();i++)
{
auto c=str[i];
cout<<c<<endl;
if(isdigit(c))
{
int j=i;
int a=0;
while(j<str.size()&&isdigit(str[j]))
{
a=a*10+str[j++]-'0';
}
// cout<<"a:"<<a<<endl;
i=j-1;
num.push(a);
}
else if(c=='(')
{
op.push(c);
}
else if(c==')')
{
while(op.top()!='(')
{
caculate();
}
cout<<"top"<<num.top()<<endl;
op.pop();
}
else
{
while(op.size()&&op.top()!='(' && mp[op.top()]>=mp[c] ) caculate();
op.push(c);
}
}
while (op.size()) caculate();
cout << num.top() << endl;
return 0;
}