Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void get_combo(int n, const std::string& str, std::string prefix, std::string* arr) {
- if (n == str.size()) {
- std::cout << prefix << " ";
- return;
- }
- for (int i = 0; i < arr[str[n] - '2'].size(); i++) {
- get_combo(n + 1, str, prefix + arr[str[n] - '2'][i], arr);
- }
- }
- int main() {
- std::string arr[8]{ "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
- std::string str;
- std::cin >> str;
- get_combo(0, str, "", arr);
- }
Advertisement
Add Comment
Please, Sign In to add comment