//服务端第三题,ac #include<iostream> #include<string> #include<vector> using namespace std; void getResult(string& temp, vector<string>& r, string& tempIn, int p) { if (p >= temp.size()) { r.push_back(tempIn); return; } tempIn.push_back(temp[p] - '0' - 1+ 'a'); getResult(temp, r, tempIn, p + 1); tempIn.pop_back(); if (temp.size()-p <= 1)return; if (temp[p] <= '2'&&temp[p + 1] <= '6' || temp[p] <= '1') { tempIn.push_back(((temp[p] - '0') * 10 + (temp[p + 1] - '0')) - 1 + 'a'); getResult(temp, r, tempIn,p + 2); tempIn.pop_back(); } } int main(void) { string temp, r, tempIn; vector<string> result; while (cin >> temp) { getResult(temp, result, tempIn, 0); for (int i = 0; i < result.size(); ++i) { for(int j=0;j<result[i].size();++j) printf("%c",result[i][j]); if (i == result.size() - 1)printf("\n"); else printf(" "); } r.clear(); tempIn.clear(); result.clear(); temp.clear(); } return 0; }
点赞 4

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务