Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- string table[] = { " ", ".+@$", "abc", "def", "ghi", "jkl" , "mno", "pqrs" , "tuv", "wxyz" };
- void possibleString(string s, string copy, int i,int j){
- if(s.length() == 0)
- return;
- if(s.length() == i){
- cout<<copy<<endl;
- return;
- }
- int digit = s[i] - '0';
- cout<<digit<<endl;
- for(int k = 0; k < table[digit].length(); k++){
- copy[j] = table[digit][k];
- cout<<copy<<endl;
- possibleString(s,copy, i+1, j+1);
- }
- return;
- }
- int main() {
- string s;
- cin>>s;
- string copy ="";
- possibleString(s,copy, 0, 0);
- return 0;
- }
Add Comment
Please, Sign In to add comment