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