#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
int v[10]={0,100,2, 1, 1, 1,0,2};// 40 41 42 43 44 45
vector<char>c;
vector<int>p;
int compute(int y,int x,char r)
{
if(r=='+') return y+x;
if(r=='-') return y-x;
if(r=='*') return y*x;
if(r=='/') return y/x;
return 0;
}
int main()
{
// char g;int h;while(cin>>g) { h=int(g); cout<<h<<endl; }
char s[30],b;
int t=0,lg,i,x,y;
cout<<"请输入一个表达式,输入end结束"<<endl;
while(gets(s))
{
if(!strcmp(s,"end")) break;
lg=strlen(s);
c.push_back('\0');
for(i=0;i<lg;i++) {
if(s[i]=='+'||s[i]=='-'||s[i]=='/'||s[i]=='*')
{
b=c.back();
if(b=='\0'||v[s[i]-'(']>v[b-'(']) c.push_back(s[i]);
else
{
c.pop_back();
x=p.back();p.pop_back();
y=p.back();p.pop_back();
t=compute(y,x,b);
p.push_back(t);
c.push_back(s[i]);
}
}
if(s[i]=='(') c.push_back(s[i]);
if(s[i]==')') {
b=c.back();c.pop_back();
while(b!='(')
{
x=p.back();p.pop_back();
y=p.back();p.pop_back();
t=compute(y,x,b);
p.push_back(t);
b=c.back();c.pop_back();
}
}
if(s[i]>='0'&&s[i]<='9')
{
t=0;
while(s[i]>='0'&&s[i]<='9')
{
t=t*10+s[i++]-'0';
}
i--;
p.push_back(t);
}
}
b=c.back();c.pop_back();
while(b!='\0')
{
x=p.back();p.pop_back();
y=p.back();p.pop_back();
t=compute(y,x,b);
p.push_back(t);
b=c.back();c.pop_back();
}
t=p.back();p.pop_back();
cout<<t<<endl;
for(i=0;i<c.size();i++)
cout<<c[i]<<endl;
}
return 0;
}