fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int myStrlen(char s[]){
  5. int i;
  6. for(i = 0; s[i] != '\0'; i++);
  7. return i;
  8. }
  9.  
  10. char *setPalindrome(char s[]) {
  11. int len = myStrlen(s);
  12. int newLen = len * 2;
  13. char *tmp = (char *)malloc((newLen + 1) * sizeof(char));
  14.  
  15. if (tmp == NULL) {
  16. return NULL;
  17. }
  18.  
  19. for (int i = 0; i < len; i++) {
  20. tmp[i] = s[i];
  21. }
  22.  
  23. for (int i = 0; i < len; i++) {
  24. tmp[len + i] = s[len - i - 1];
  25. }
  26.  
  27. tmp[newLen] = '\0';
  28. return tmp;
  29. }
  30.  
  31. int main() {
  32. char nyuryoku[1024];
  33. char *kaibun;
  34. scanf("%s", nyuryoku);
  35. kaibun = setPalindrome(nyuryoku);
  36.  
  37. printf("%s\n -> %s\n", nyuryoku, kaibun);
  38. free(kaibun);
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
19**j
  -> 19**jj**91