fork download
  1. #include <iostream>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. char keypad[][10] = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  6.  
  7. void printPermutet(char *in,char *out,int i,int j){
  8. if(in[i] == '\0'){
  9. out[j] = '\0';
  10. cout<<out<<endl;
  11. return;
  12. }
  13. int p = in[i] - '0';
  14. for(int k=0;keypad[p][k]!='\0';k++){
  15. out[j] = keypad[p][k];
  16. printPermutet(in,out,i+1,j+1);
  17. }
  18. return;
  19. }
  20.  
  21. int main() {
  22. char in[100];
  23. char out[100];
  24. cin>>in;
  25. printPermutet(in,out,0,0);
  26. return 0;
  27. }
Success #stdin #stdout 0s 15240KB
stdin
247
stdout
agp
agq
agr
ags
ahp
ahq
ahr
ahs
aip
aiq
air
ais
bgp
bgq
bgr
bgs
bhp
bhq
bhr
bhs
bip
biq
bir
bis
cgp
cgq
cgr
cgs
chp
chq
chr
chs
cip
ciq
cir
cis