class Solution {
public:
int evalRPN(vector<string>& tokens)
{
int ret = 0;
stack<int> st;
int x, y;
for (int i = 0; i < tokens.size(); i++)
{
if (tokens[i] == "+" || tokens[i] == "-" || tokens[i] == "*" || tokens[i] == "/")
{
x = st.top();
st.pop();
y = st.top();
st.pop();
if (tokens[i] == "+") st.push(y + x);
else if (tokens[i] == "-") st.push(y - x);
else if (tokens[i] == "*") st.push(y * x);
else st.push(y / x);
}
else
st.push(stoi(tokens[i]));//stoi将string字符串变成十进制数字
}
return st.top();
}
};