#include <iostream> #include <set> using namespace std; string instr; void decrypt(int ith, string nowstr, set<string> &v) {     if(ith >= instr.size())     {         v.insert(nowstr);         return;     }     int num;     for(int i = 1; i <= 2; i++)     {         if(instr[ith] == '0')             break;         if(i == 1)             num = instr[ith] - '0';         else         {             if(ith >= (instr.size() - 1))                 break;             num = (instr[ith] - '0') * 10 + (instr[ith + 1] - '0');             if(num > 26)                 break;         }         char temp = 'a' + (num - 1);         decrypt(ith + i, nowstr + temp, v);     } } int main() {     while(cin >> instr)     {         set<string> result;         decrypt(0, "", result);         set<string>::iterator it;         for(it = result.begin(); it != result.end(); it++) {             if(it != result.begin())                 cout << ' ';             cout << *it;         }         cout << endl;     }     return 0; } 这是我ac了的代码,毕竟考试写的,可读性绝对是差,你可以看看错哪了……看不明白可以问我……
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务