#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;
int i;
tmp
= (char *)malloc((total
+ 1) * sizeof(char));
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(){
int i;
char nyuryoku[1024];
char *kaibun;
kaibun = setPalindrome(nyuryoku);
printf("%s\n -> %s\n", nyuryoku
, kaibun
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpID0gMDsgc1tpXSAhPSAnXDAnOyBpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewogICAgY2hhciAqdG1wOwogICAgaW50IGxlbiA9IG15U3RybGVuKHMpOwogICAgaW50IHRvdGFsID0gbGVuICogMjsKICAgIGludCBpOwoKICAgIHRtcCA9IChjaGFyICopbWFsbG9jKCh0b3RhbCArIDEpICogc2l6ZW9mKGNoYXIpKTsKCiAgICBmb3IoaSA9IDA7IGkgPCBsZW47IGkrKyl7CiAgICAgICAgdG1wW2ldID0gc1tpXTsKICAgIH0KCiAgICBmb3IoaSA9IDA7IGkgPCBsZW47IGkrKyl7CiAgICAgICAgdG1wW2xlbiArIGldID0gc1tsZW4gLSAxIC0gaV07CiAgICB9CgogICAgdG1wW3RvdGFsXSA9ICdcMCc7CgogICAgcmV0dXJuIHRtcDsKfQoKaW50IG1haW4oKXsKICAgIGludCBpOwogICAgY2hhciBueXVyeW9rdVsxMDI0XTsKICAgIGNoYXIgKmthaWJ1bjsgIAogICAgc2NhbmYoIiVzIiwgbnl1cnlva3UpOwogICAga2FpYnVuID0gc2V0UGFsaW5kcm9tZShueXVyeW9rdSk7CiAgICBwcmludGYoIiVzXG4gIC0+ICVzXG4iLCBueXVyeW9rdSwga2FpYnVuKTsKICAgIGZyZWUoa2FpYnVuKTsKICAgIHJldHVybiAwOwp9Cg==