#include <stdio.h>
#include <stdlib.h>
int myStrlen(char s[]){
int i;
for(i=0;s[i]!='\0';i++);
return i;
}
// 関数の中でtmpに対してmallocして
// そこに回文を代入してreturnで返しましょう
char *setPalindrome(char s[]){
char *tmp;
int i,size;
size=myStrlen(s);
tmp
=(char*)malloc(sizeof(char)*(2*size
+1)); if(tmp==NULL){
return NULL;
}
for(i=0;i<size;i++) tmp[i]=s[i];
for(i=0;i<size;i++) tmp[i+size]=s[size-i-1];
tmp[2*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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KIAppbnQgbXlTdHJsZW4oY2hhciBzW10pewogICAgaW50IGk7CiAgICBmb3IoaT0wO3NbaV0hPSdcMCc7aSsrKTsKICAgIHJldHVybiBpOwp9CiAKLy8g6Zai5pWw44Gu5Lit44GndG1w44Gr5a++44GX44GmbWFsbG9j44GX44GmCi8vIOOBneOBk+OBq+WbnuaWh+OCkuS7o+WFpeOBl+OBpnJldHVybuOBp+i/lOOBl+OBvuOBl+OCh+OBhgpjaGFyICpzZXRQYWxpbmRyb21lKGNoYXIgc1tdKXsKCWNoYXIgKnRtcDsKCWludCBpLHNpemU7CglzaXplPW15U3RybGVuKHMpOwoJdG1wPShjaGFyKiltYWxsb2Moc2l6ZW9mKGNoYXIpKigyKnNpemUrMSkpOwoJaWYodG1wPT1OVUxMKXsKCQlwcmludGYoIkVycm9yXG4iKTsKCQlyZXR1cm4gTlVMTDsKCX0KCWZvcihpPTA7aTxzaXplO2krKykgdG1wW2ldPXNbaV07Cglmb3IoaT0wO2k8c2l6ZTtpKyspIHRtcFtpK3NpemVdPXNbc2l6ZS1pLTFdOwoJdG1wWzIqc2l6ZV09J1wwJzsKCXJldHVybiB0bXA7Cn0KIAogCi8v44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