Guest User

Untitled

a guest
Jan 2nd, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. string table[] = { " ", ".+@$", "abc", "def", "ghi", "jkl" , "mno", "pqrs" , "tuv", "wxyz" };
  5. void possibleString(string s, string copy, int i,int j){
  6.     if(s.length() == 0)
  7.         return;
  8.     if(s.length() == i){
  9.         cout<<copy<<endl;
  10.         return;
  11.     }
  12.     int digit = s[i] - '0';
  13.     cout<<digit<<endl;
  14.    
  15.     for(int k = 0; k < table[digit].length(); k++){
  16.         copy[j] = table[digit][k];
  17.         cout<<copy<<endl;
  18.         possibleString(s,copy, i+1, j+1);
  19.     }
  20.     return;
  21. }
  22.  
  23. int main() {
  24.    
  25.     string s;
  26.     cin>>s;
  27.     string copy ="";
  28.     possibleString(s,copy, 0, 0);
  29.    
  30.     return 0;
  31. }
Add Comment
Please, Sign In to add comment