void GetAllString(int start, string & str, vector<string> & res) { if (start == str.size()) { res.push_back(str); } else { bool has = false; for (int i = start; i < str.size(); i++) { if (str[i] == ‘*‘) { str[i] = ‘1‘; GetAllString(i + 1, str, res); str[i] = ‘2‘; GetAllString(i + 1, str, res); str[i] = ‘*‘; has = true; break; } } if (!has) res.push_back(str); } } vector<string> GetAllString(string str) { vector<string> res; GetAllString(0, str, res); return res; }
时间: 2024-10-31 07:56:07