Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- using namespace std;
- char a[][10] = {"", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wx", "yz"};
- string temp;
- void print(char *s, char *out, int i, int j, int &count){
- if(s[i] == '\0'){
- out[j] = '\0';
- cout<<out<<" ";
- count++;
- return;
- }
- int digit = temp[i] - '0';
- for(int k = 0; a[digit][k] != '\0'; k++){
- out[j] = a[digit][k];
- print(s, out , i + 1, j + 1, count);
- }
- }
- int main() {
- cin>>temp;
- char *s = new char[temp.length() + 1];
- char *p = new char[temp.length() + 1];
- int count = 0;
- print(s, p, 0, 0, count);
- cout<<"\n"<<count<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment