35657

Untitled

Jun 7th, 2024
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4.  
  5.  
  6. void get_combo(const std::string& str, std::vector<std::string>& arr, std::string prefix = "", int index = 0) {
  7.     if (index == str.size()) {
  8.         std::cout << prefix << " ";
  9.     }
  10.     else {
  11.         for (int i = 0; i < arr[str[index] - '2'].size(); i++) {
  12.             get_combo(str, arr, prefix + arr[str[index] - '2'][i], index + 1);
  13.         }
  14.     }
  15. }
  16.  
  17. int main() {
  18.     setlocale(LC_ALL, "ru");
  19.  
  20.     std::vector<std::string> arr{ "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
  21.  
  22.     std::string str;
  23.  
  24.     std::cin >> str;
  25.    
  26.     get_combo(str, arr);
  27. }
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment