#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[]){
char *tmp;
int len = myStrlen(s);
int total = len * 2;
tmp
= (char *)malloc((total
+ 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[total] = '\0';
return tmp;
}
int main(){
char nyuryoku[1024];
char *kaibun;
kaibun = setPalindrome(nyuryoku);
printf("%s\n -> %s\n", nyuryoku
, kaibun
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpID0gMDsgc1tpXSAhPSAnXDAnOyBpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewogICAgY2hhciAqdG1wOwogICAgaW50IGxlbiA9IG15U3RybGVuKHMpOyAgICAgICAKICAgIGludCB0b3RhbCA9IGxlbiAqIDI7ICAgICAgICAgCiAgICB0bXAgPSAoY2hhciAqKW1hbGxvYygodG90YWwgKyAxKSAqIHNpemVvZihjaGFyKSk7CiAgICBpbnQgaTsKICAgIGZvcihpID0gMDsgaSA8IGxlbjsgaSsrKXsKICAgICAgICB0bXBbaV0gPSBzW2ldOwogICAgfQogICAgZm9yKGkgPSAwOyBpIDwgbGVuOyBpKyspewogICAgICAgIHRtcFtsZW4gKyBpXSA9IHNbbGVuIC0gMSAtIGldOwogICAgfQogICAgdG1wW3RvdGFsXSA9ICdcMCc7CiAgICByZXR1cm4gdG1wOwp9CgppbnQgbWFpbigpewogICAgY2hhciBueXVyeW9rdVsxMDI0XTsgCiAgICBjaGFyICprYWlidW47CiAgICBzY2FuZigiJXMiLCBueXVyeW9rdSk7CiAgICBrYWlidW4gPSBzZXRQYWxpbmRyb21lKG55dXJ5b2t1KTsKICAgIHByaW50ZigiJXNcbiAgLT4gJXNcbiIsIG55dXJ5b2t1LCBrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0=