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