#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 totalLength = 2 * len;
char *tmp
= (char *)malloc((totalLength
+ 1) * sizeof(char));
for (int i = 0; i < len; i++){
tmp[i] = s[i];
tmp[totalLength - 1 - i] = s[i];
}
tmp[totalLength] = '\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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpPTA7c1tpXSE9J1wwJztpKyspOwogICAgcmV0dXJuIGk7Cn0KCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pewoJaW50IGxlbiA9IG15U3RybGVuKHMpOwoJaW50IHRvdGFsTGVuZ3RoID0gMiAqIGxlbjsKCWNoYXIgKnRtcCA9IChjaGFyICopbWFsbG9jKCh0b3RhbExlbmd0aCArIDEpICogc2l6ZW9mKGNoYXIpKTsKCQoKCWZvciAoaW50IGkgPSAwOyBpIDwgbGVuOyBpKyspewoJCXRtcFtpXSA9IHNbaV07CgkJdG1wW3RvdGFsTGVuZ3RoIC0gMSAtIGldID0gc1tpXTsKCX0KCXRtcFt0b3RhbExlbmd0aF0gPSAnXDAnOwoJCglyZXR1cm4gdG1wOwp9CgppbnQgbWFpbigpewogICAgaW50IGk7CiAgICBjaGFyIG55dXJ5b2t1WzEwMjRdOyAvL+WFpeWKmwogICAgY2hhciAqa2FpYnVuOyAgIC8v5Zue5paH44KS5Y+X44GR5Y+W44KLCiAgICBzY2FuZigiJXMiLG55dXJ5b2t1KTsKICAgIGthaWJ1biA9IHNldFBhbGluZHJvbWUobnl1cnlva3UpOwogICAgcHJpbnRmKCIlc1xuICAtPiAlc1xuIixueXVyeW9rdSxrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0K