#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,j;
char*tmp
=(char*)malloc((2*len
+1)*sizeof(char)); if(tmp==NULL){
return NULL;
}
for(i=0;i<len;i++){
tmp[i]=s[i];
}
for(i=0,j=len;i<len;i++,j++){
tmp[j]=s[len-i-1];
}
tmp[2*len]='\0';
return tmp;
}
int main(){
char nyuryoku[1024];
char *kaibun;
kaibun=setPalindrome(nyuryoku);
if(kaibun==NULL){
return 1;
}
printf("%s\n->%s\n",nyuryoku
,kaibun
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpPTA7c1tpXSE9J1wwJztpKyspOwogICAgcmV0dXJuIGk7Cn0KY2hhciAqc2V0UGFsaW5kcm9tZShjaGFyIHNbXSl7CiAgICBpbnQgbGVuPW15U3RybGVuKHMpOwogICAgaW50IGksajsKICAgIGNoYXIqdG1wPShjaGFyKiltYWxsb2MoKDIqbGVuKzEpKnNpemVvZihjaGFyKSk7CiAgICBpZih0bXA9PU5VTEwpewogICAgICAgIHJldHVybiBOVUxMOwogICAgfQogICAgZm9yKGk9MDtpPGxlbjtpKyspewogICAgICAgIHRtcFtpXT1zW2ldOwogICAgfQogICAgZm9yKGk9MCxqPWxlbjtpPGxlbjtpKyssaisrKXsKICAgICAgICB0bXBbal09c1tsZW4taS0xXTsKICAgIH0KICAgIHRtcFsyKmxlbl09J1wwJzsKICAgIHJldHVybiB0bXA7Cn0KaW50IG1haW4oKXsKICAgIGNoYXIgbnl1cnlva3VbMTAyNF07CiAgICBjaGFyICprYWlidW47ICAgICAgICAKICAgIHNjYW5mKCIlcyIsbnl1cnlva3UpOwogICAga2FpYnVuPXNldFBhbGluZHJvbWUobnl1cnlva3UpOwogICAgaWYoa2FpYnVuPT1OVUxMKXsKICAgICAgICBwcmludGYoIuODoeODouODquOBrueiuuS/neOBq+WkseaVl+OBl+OBvuOBl+OBn+OAglxuIik7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBwcmludGYoIiVzXG4tPiVzXG4iLG55dXJ5b2t1LGthaWJ1bik7CiAgICBmcmVlKGthaWJ1bik7CiAgICByZXR1cm4gMDsKfQ==