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