bramasole @ 2019-08-05 19:39:28
#include <iostream>
using namespace std;
const int MAXN=1000;
string S;
int A[MAXN];
int Stack[MAXN],top;
int main(int argc, const char * argv[]) {
// insert code here...
cin>>S;
int l=S.size();
int x,y,z;
for(int i=0;i<l;i++)
{
if((S[i]>='0')&&(S[i]<='9'))
{
Stack[top]=S[i]-'0';
top++;
}
if(S[i]=='+')
{
y=Stack[top-1];
x=Stack[top-2];
top=top-2;
z=x+y;
Stack[top]=z;
top++;
}
if(S[i]=='-')
{
y=Stack[top-1];
x=Stack[top-2];
top=top-2;
z=x-y;
Stack[top]=z;
top++;
}
if(S[i]=='*')
{
y=Stack[top-1];
x=Stack[top-2];
top=top-2;
z=x*y;
Stack[top]=z;
top++;
}
if(S[i]=='/')
{
y=Stack[top-1];
x=Stack[top-2];
top=top-2;
z=x/y;
Stack[top]=z;
top++;
}
}
int ans=Stack[top-1];
cout<<ans;
return 0;
}