#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 i, j;
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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSkgewogICAgaW50IGk7CiAgICBmb3IgKGkgPSAwOyBzW2ldICE9ICdcMCc7IGkrKyk7CiAgICByZXR1cm4gaTsKfQpjaGFyICpzZXRQYWxpbmRyb21lKGNoYXIgc1tdKSB7CiAgICBjaGFyICp0bXA7CiAgICBpbnQgbGVuID0gbXlTdHJsZW4ocyk7IAogICAgaW50IGksIGo7CgogICAgdG1wID0gKGNoYXIgKiltYWxsb2MoKDIgKiBsZW4gKyAxKSAqIHNpemVvZihjaGFyKSk7IAoKICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgIHRtcFtpXSA9IHNbaV07CiAgICB9CiAgICBmb3IgKGogPSBsZW4gLSAxOyBqID49IDA7IGotLSkgewogICAgICAgIHRtcFtpKytdID0gc1tqXTsKICAgIH0KCiAgICB0bXBbaV0gPSAnXDAnOwoKICAgIHJldHVybiB0bXA7Cn0KCmludCBtYWluKCkgewogICAgaW50IGk7CiAgICBjaGFyIG55dXJ5b2t1WzEwMjRdOyAKICAgIGNoYXIgKmthaWJ1bjsgICAgICAgIAogICAgc2NhbmYoIiVzIiwgbnl1cnlva3UpOwogICAga2FpYnVuID0gc2V0UGFsaW5kcm9tZShueXVyeW9rdSk7CiAgICBwcmludGYoIiVzXG4gIC0+ICVzXG4iLCBueXVyeW9rdSwga2FpYnVuKTsKICAgIGZyZWUoa2FpYnVuKTsKICAgIHJldHVybiAwOwp9Cg==