#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
map<int, string> numtostr{
{2,"abc"},
{3,"def"},
{4,"hij"},
{5,"klm"},
{6,"nop"},
{7,"qrs"},
{8,"tuv"},
{9,"wzx"} };
vector <string>res;
class solution
{
public:
vector<string> test(string digital)
{
string tmp = "";
if (digital.length() == 0)
{
res.push_back(tmp);
return res;
}
dfs(digital, tmp, 0);
return res;
}
private:
void dfs(string digital, string tmp, int index)
{
if (index == digital.length())
{
res.push_back(tmp);
return;
}
int k = digital[index] - '0';
for (int i = 0; i < numtostr[k].length(); i++)
dfs(digital,tmp+numtostr[k][i],index+1);
}
};
int main()
{
string tmp = "234";
class solution a;
vector<string> res=a.test(tmp);
for (int i = 0; i < res.size(); i++)
cout << res[i] << endl;
system("pause");
return 0;
}