fork(1) download
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int counter(char s[]){
  5. int i=0;
  6. while(s[i]!='\0')
  7. {
  8. i++;
  9. };
  10. return i;
  11. };
  12.  
  13. char* setPalindrome(char s[]){
  14. int i;
  15. int k=0;
  16. i=counter(s);
  17. char*tmp=(char*)malloc(sizeof(char)*i*2+1);
  18. for(k;k<i;k++){
  19. tmp[k]=s[k];
  20. };
  21. for(int j=0;j<i;j++){
  22. tmp[i+j-1]=s[i-j];
  23. printf("%c,%c",tmp[i+j-1],s[i-j]);
  24. };
  25. tmp[i*2]='\0';
  26. return tmp;
  27. };
  28.  
  29.  
  30. int main(){
  31. char s[100];
  32. char* t;
  33. scanf("%s",s);
  34. t=setPalindrome(s);
  35. printf("%s",t);
  36. free(t);
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 5348KB
stdin
ghi
stdout
,i,ih,hgh