(1)分治法
class Solution {
public:
vector<int> diffWaysToCompute(string e) {
vector<int> v1,v2,vec;
int tag=0;
for(int i=0;i<e.length();i++) {
if(e[i]=='+' || e[i]=='-' || e[i]=='*') {
tag=1;
v1=diffWaysToCompute(string(e,0,i));
v2=diffWaysToCompute(string(e,i+1,e.length()-i-1));
for(int j=0;j<v1.size();j++) {
for(int k=0;k<v2.size();k++) {
if(e[i]=='+') vec.push_back(v1[j]+v2[k]);
else if(e[i]=='-') vec.push_back(v1[j]-v2[k]);
else if(e[i]=='*') vec.push_back(v1[j]*v2[k]);
}
}
}
}
if(tag==0) return {stoi(e)};
return vec;
}
};