#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 l=myStrlen(s);
char *tmp
=(char *)malloc(sizeof(char)*(2*l
+1)); if(tmp==NULL){
return 0;
}
for(int i=0;i<l;i++){
tmp[i]=s[i];
tmp[l+i]=s[l-i-1];
}
tmp[2*l]='\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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpPTA7c1tpXSE9J1wwJztpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewoJaW50IGw9bXlTdHJsZW4ocyk7CgljaGFyICp0bXA9KGNoYXIgKiltYWxsb2Moc2l6ZW9mKGNoYXIpKigyKmwrMSkpOwoJaWYodG1wPT1OVUxMKXsKCQlwcmludGYoIkVSUk9SXG4iKTsKCXJldHVybiAwOwoJfQoJZm9yKGludCBpPTA7aTxsO2krKyl7CgkJdG1wW2ldPXNbaV07CgkJdG1wW2wraV09c1tsLWktMV07Cgl9Cgl0bXBbMipsXT0nXDAnOwoJcmV0dXJuIHRtcDsKfQoKaW50IG1haW4oKXsKICAgIGludCBpOwogICAgY2hhciBueXVyeW9rdVsxMDI0XTsgLy/lhaXlipsKICAgIGNoYXIgKmthaWJ1bjsgICAvL+WbnuaWh+OCkuWPl+OBkeWPluOCiwogICAgc2NhbmYoIiVzIixueXVyeW9rdSk7CiAgICBrYWlidW4gPSBzZXRQYWxpbmRyb21lKG55dXJ5b2t1KTsKICAgIHByaW50ZigiJXNcbiAgLT4gJXNcbiIsbnl1cnlva3Usa2FpYnVuKTsKICAgIGZyZWUoa2FpYnVuKTsKICAgIHJldHVybiAwOwp9Cg==