水一篇没啥难度的
题目:luoguP1449
#include <iostream>
#include <cstring>
#include <stack>
using namespace std;
stack<int> stk;
int cal(int a, int b, char o){
if(o == '+') return a+b;
else if(o == '-') return a-b;
else if(o == '*') return a*b;
else return a/b;
}
int main()
{
while(cin.peek() != '@'){
if(isdigit(cin.peek())){
int a = 0;
while(isdigit(cin.peek())){
a *= 10;
a += cin.get() - '0';
}
stk.push(a);
}
else if(cin.peek() == '.'){
cin.get();
continue;
}
else{
char o = cin.get();
int a = stk.top(); stk.pop();
int b = stk.top(); stk.pop();
int c = cal(b, a, o);
stk.push(c);
}
}
cout << stk.top() << endl;
system("pause");
return 0;
}