很简单是数据结构题,调库其实也很好用
#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;
stack<int> S;
int main()
{
char c;
while(true)
{
c=getchar();
if(c=='+')
{
int a=S.top();
S.pop();
int b=S.top();
S.pop();
S.push(a+b);
}
else if(c=='-')
{
int a=S.top();
S.pop();
int b=S.top();
S.pop();
S.push(b-a);
}
else if(c=='*')
{
int a=S.top();
S.pop();
int b=S.top();
S.pop();
S.push(a*b);
}
else
{
ungetc(c,stdin);
int a;
scanf("%d",&a);
S.push(a);
}
c=getchar();
if(c=='\n')
{
break;
}
}
int a;
a=S.top();
printf("%d\n",a);
return 0;
}