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