Guest User

Untitled

a guest
Jun 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include<iostream>
  2. #include<bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. const char A[10][5]={ "", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};``
  7.  
  8.  
  9. void rec_print(int arr[],int current,int str_length,char output[]){
  10.  
  11.  
  12. if(current==str_length){
  13. cout<<output<<" ";
  14. return;
  15. }
  16. int i;
  17. for(i=0;i<strlen(A[arr[current]]);i++){
  18. output[current]=A[arr[current]][i];
  19. rec_print(arr,current+1,str_length,output);
  20. }
  21.  
  22. }
  23.  
  24. void printString(int ar[],int l){
  25.  
  26. char op[l];
  27. rec_print(ar,0,l,op);
  28. }
  29.  
  30. int main() {
  31. //code
  32.  
  33. int t;
  34. cin>>t;
  35. while(t--){
  36. int n;
  37. cin>>n;
  38. int arr[n];
  39. for(int i=0;i<n;i++){
  40. cin>>arr[i];
  41. }
  42. printString(arr,n);
  43. }
  44.  
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment