fork download
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4. #include <string.h>
  5. void permute(char *arr);
  6. int main() {
  7. // your code goes here
  8. char s[1000];
  9. memset(s,'\0',1000);
  10. cin>>s;
  11. //cout<<s[0]<<s[1];
  12. permute(s);
  13. return 0;
  14. }
  15.  
  16. void permute(char *arr)
  17. {
  18. /* char *temp = arr;
  19. int i=0;
  20. while(temp[i]!='\0')
  21. {
  22. //cout<<temp[i];
  23. //temp++;
  24. cout<<i++;
  25. }
  26. */
  27. //cout<<*arr;
  28. char map[] = {' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  29. if(*arr == '\0')
  30. {
  31. // cout<<"a";
  32. return;
  33. }
  34. int i = (int)(*arr)-48;
  35. //cout<<i;
  36. printf("%c",map[i]);
  37. //permute(arr+1);
  38. char first[] = {*arr};
  39. cout<<first;
  40. char second[] = {*(arr+1)};
  41. char *j = strcat(first,second);
  42. cout<<j;
  43. //printf("%c%c",map[i],map[j]);
  44. //permute(arr+2);
  45. return;
  46.  
  47. }
Runtime error #stdin #stdout 0s 3300KB
stdin
123
stdout
Standard output is empty