#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
) { printf("ERROR\n"); return 0; } 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+OBhgpjaGFyICpzZXRQYWxpbmRyb21lKGNoYXIgc1tdKXsKCWNoYXIgKnRtcDsKICAgIGludCBpLHNpemU7CiAgICBzaXplPW15U3RybGVuKHMpOwogICAgdG1wPShjaGFyKiltYWxsb2Moc2l6ZW9mKGNoYXIpKigyKnNpemUrMSkpOwogICAgaWYodG1wPT1OVUxMKSB7IHByaW50ZigiRVJST1JcbiIpOyByZXR1cm4gMDsgfQogICAgZm9yKGk9MDtpPHNpemU7aSsrKSB7IHRtcFtpXT1zW2ldOyB9CiAgICBmb3IoaT0wO2k8c2l6ZTtpKyspIHsgdG1wW2krc2l6ZV09c1tzaXplLWktMV07IH0KICAgIHRtc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