#include <iostream>
#include <string>
using namespace std;
char LetterMap[10][5] =
{
" ",
"",
"abc",
"def",
"ghi",
"jkl",
"mno",
"pqrs",
"tuv",
"wxyz"
};
void LetterCombinations(string& digits, string letters)
{
if (digits.size() == letters.size())
{
cout << letters << '\n';
return;
}
int num = digits[letters.size()] - '0';
char * letter = LetterMap[num];
while(*letter != '\0')
{
LetterCombinations(digits, letters + *letter);
++ letter;
}
}
int main(int argc, char** argv)
{
string dig1 = "7";
string dig2 = "23";
string dig3 = "234";
cout << dig1 <<":\n";
LetterCombinations(dig1, "");
cout << endl;
cout << dig2 <<":\n";
LetterCombinations(dig2, "");
cout << endl;
cout << dig3 <<":\n";
LetterCombinations(dig3, "");
cout << endl;
return 0;
}