#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 new_len = len * 2;
tmp
= (char*)malloc((new_len
+ 1) * sizeof(char));
if (tmp == NULL) {
return NULL;
}
int i, j;
for (i = 0; i < len; i++) {
tmp[i] = s[i];
}
for (j = len - 1; j >= 0; j--) {
tmp[i] = s[j];
i++;
}
tmp[new_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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpPTA7c1tpXSE9J1wwJztpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewoJY2hhciAqdG1wOwogICAgaW50IGxlbiA9IG15U3RybGVuKHMpOwogICAgaW50IG5ld19sZW4gPSBsZW4gKiAyOyAKCgogICAgdG1wID0gKGNoYXIqKW1hbGxvYygobmV3X2xlbiArIDEpICogc2l6ZW9mKGNoYXIpKTsKICAgIAogICAgaWYgKHRtcCA9PSBOVUxMKSB7CiAgICAgICAgcmV0dXJuIE5VTEw7CiAgICB9CiAgICAKICAgIGludCBpLCBqOwogICAgCiAgICBmb3IgKGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICB0bXBbaV0gPSBzW2ldOwogICAgfQogICAgCiAgIAogICAgZm9yIChqID0gbGVuIC0gMTsgaiA+PSAwOyBqLS0pIHsKICAgICAgICB0bXBbaV0gPSBzW2pdOwogICAgICAgIGkrKzsKICAgIH0KCiAgICB0bXBbbmV3X2xlbl0gPSAnXDAnOwogICAgCiAgICByZXR1cm4gdG1wOwp9CgoKaW50IG1haW4oKXsKICAgIGludCBpOwogICAgY2hhciBueXVyeW9rdVsxMDI0XTsgCiAgICBjaGFyICprYWlidW47ICAgIAogICAgc2NhbmYoIiVzIixueXVyeW9rdSk7CiAgICBrYWlidW4gPSBzZXRQYWxpbmRyb21lKG55dXJ5b2t1KTsKICAgIHByaW50ZigiJXNcbiAtPiAlc1xuIixueXVyeW9rdSxrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0=