#include <stdio.h>
#include <stdlib.h>
int myStrlen(char s[]){
int i;
for(i = 0; s[i] != '\0'; i++);
return i;
}
char *setPalindrome(char s[]){
int len = myStrlen(s);
int totalLen = len * 2;
char *tmp
= (char *)malloc((totalLen
+ 1) * sizeof(char)); int i;
for(i = 0; i < len; i++){
tmp[i] = s[i];
}
for(i = 0; i < len; i++){
tmp[len + i] = s[len - 1 - i];
}
tmp[totalLen] = '\0';
return tmp;
}
int main(){
int i;
char nyuryoku[1024];
char *kaibun;
kaibun = setPalindrome(nyuryoku);
printf("%s\n →%s\n", nyuryoku
, kaibun
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpID0gMDsgc1tpXSAhPSAnXDAnOyBpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewogICAgaW50IGxlbiA9IG15U3RybGVuKHMpOwogICAgaW50IHRvdGFsTGVuID0gbGVuICogMjsKICAgIGNoYXIgKnRtcCA9IChjaGFyICopbWFsbG9jKCh0b3RhbExlbiArIDEpICogc2l6ZW9mKGNoYXIpKTsgCiAgICBpbnQgaTsKCiAgICBmb3IoaSA9IDA7IGkgPCBsZW47IGkrKyl7CiAgICAgICAgdG1wW2ldID0gc1tpXTsKICAgIH0KCiAgICBmb3IoaSA9IDA7IGkgPCBsZW47IGkrKyl7CiAgICAgICAgdG1wW2xlbiArIGldID0gc1tsZW4gLSAxIC0gaV07CiAgICB9CgogICAgdG1wW3RvdGFsTGVuXSA9ICdcMCc7IAoKICAgIHJldHVybiB0bXA7Cn0KCmludCBtYWluKCl7CiAgICBpbnQgaTsKICAgIGNoYXIgbnl1cnlva3VbMTAyNF07IAogICAgY2hhciAqa2FpYnVuOyAgICAgICAgCiAgICBzY2FuZigiJXMiLCBueXVyeW9rdSk7CiAgICBrYWlidW4gPSBzZXRQYWxpbmRyb21lKG55dXJ5b2t1KTsKICAgIHByaW50ZigiJXNcbiAg4oaSJXNcbiIsIG55dXJ5b2t1LCBrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0K