#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 i, j;
char *tmp
= (char *)malloc((2 * len
+ 1) * sizeof(char));
for(i = 0; i < len; i++) {
tmp[i] = s[i];
}
for(j = len - 1; j >= 0; j--) {
tmp[i++] = s[j];
}
tmp[i] = '\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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpID0gMDsgc1tpXSAhPSAnXDAnOyBpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewogICAgaW50IGxlbiA9IG15U3RybGVuKHMpOyAKICAgIGludCBpLCBqOwoKICAgIGNoYXIgKnRtcCA9IChjaGFyICopbWFsbG9jKCgyICogbGVuICsgMSkgKiBzaXplb2YoY2hhcikpOwoKICAgIGZvcihpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgdG1wW2ldID0gc1tpXTsKICAgIH0KCiAgICBmb3IoaiA9IGxlbiAtIDE7IGogPj0gMDsgai0tKSB7CiAgICAgICAgdG1wW2krK10gPSBzW2pdOwogICAgfQoKICAgIHRtcFtpXSA9ICdcMCc7CgogICAgcmV0dXJuIHRtcDsKfQoKaW50IG1haW4oKXsKICAgIGludCBpOwogICAgY2hhciBueXVyeW9rdVsxMDI0XTsgCiAgICBjaGFyICprYWlidW47ICAgICAgICAKICAgIHNjYW5mKCIlcyIsIG55dXJ5b2t1KTsKICAgIGthaWJ1biA9IHNldFBhbGluZHJvbWUobnl1cnlva3UpOwogICAgcHJpbnRmKCIlc1xuICAtPiAlc1xuIiwgbnl1cnlva3UsIGthaWJ1bik7CiAgICBmcmVlKGthaWJ1bik7CiAgICByZXR1cm4gMDsKfQo=