#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);
char *tmp
= (char *)malloc(2 * len
+ 1); if(tmp == NULL) {
}
for(int i = 0; i < len; i++) {
tmp[i] = s[i];
}
for(int i = 0; i < len; i++) {
tmp[len + i] = s[len - 1 - i];
}
tmp[2 * len] = '\0';
return tmp;
}
int main() {
char nyuryoku[1024];
char *kaibun;
kaibun = setPalindrome(nyuryoku);
printf("%s\n -> %s\n", nyuryoku
, kaibun
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSkgewogICAgaW50IGk7CiAgICBmb3IoaSA9IDA7IHNbaV0gIT0gJ1wwJzsgaSsrKTsKICAgIHJldHVybiBpOwp9CgpjaGFyICpzZXRQYWxpbmRyb21lKGNoYXIgc1tdKSB7CiAgICBpbnQgbGVuID0gbXlTdHJsZW4ocyk7CiAgICBjaGFyICp0bXAgPSAoY2hhciAqKW1hbGxvYygyICogbGVuICsgMSk7CiAgICBpZih0bXAgPT0gTlVMTCkgewogICAgICAgIHByaW50Zigi44Oh44Oi44Oq44Gu56K65L+d44Gr5aSx5pWX44GX44G+44GX44GfXG4iKTsKICAgICAgICBleGl0KDEpOwogICAgfQoKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgIHRtcFtpXSA9IHNbaV07CiAgICB9CgogICAgZm9yKGludCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgdG1wW2xlbiArIGldID0gc1tsZW4gLSAxIC0gaV07CiAgICB9CgogICAgdG1wWzIgKiBsZW5dID0gJ1wwJzsKCiAgICByZXR1cm4gdG1wOwp9CgppbnQgbWFpbigpIHsKICAgIGNoYXIgbnl1cnlva3VbMTAyNF07IAogICAgY2hhciAqa2FpYnVuOyAgICAgICAgCiAgICBzY2FuZigiJXMiLCBueXVyeW9rdSk7CiAgICBrYWlidW4gPSBzZXRQYWxpbmRyb21lKG55dXJ5b2t1KTsKICAgIHByaW50ZigiJXNcbiAgLT4gJXNcbiIsIG55dXJ5b2t1LCBrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0=