https://leetcode.cn/problems/evaluate-reverse-polish-notation/description/
理解了逆波兰表达式的规则,按规则写就行,比较简单
int evalRPN(vector<string>& tokens) {
stack<int> stk;
for (string s : tokens) {
if (s == "+") {
int tmp = stk.top();
stk.pop();
stk.top() += tmp;
} else if(s == "-"){
int tmp = stk.top();
stk.pop();
stk.top() -= tmp;
} else if(s == "*"){
int tmp = stk.top();
stk.pop();
stk.top() *= tmp;
} else if(s == "/"){
int tmp = stk.top();
stk.pop();
stk.top() /= tmp;
} else {
stk.push(stoi(s));
}
}
return stk.top();
}