#include<iostream>
using namespace std;
int Op(int a,char op,int b)
{
if(op=='+')
return a+b;
if(op=='-')
return a-b;
if(op=='*')
return a*b;
if(op=='/')
{
if(b==0){
cout<<"数据错误!"<<endl;
return 0;
}
else
return a/b;
}
}
int com(char s[],int n){
int i,a,b,c;
int stack[100];
int top=-1;
char op; //op代表操作运算符
for(i=0;i<n;i++){
if(s[i]>='0'&&s[i]<='9')
stack[++top]=s[i]-'0';
else{
op=s[i];
b=stack[top--];
a=stack[top--];
c=Op(a,op,b);
stack[++top]=c;
}
}
return stack[top];
}
int main()
{
char a[100];
cout<<"请输入字符串的数据:"<<endl;
cin>>a;
int result=com(a,strlen(a));
cout<<result<<endl;
return 0;
}