#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[])
{
int i;
int count = myStrlen(s);
char *tmp;
tmp
= (char*)malloc(sizeof(char)*(2*count
+1)); for(i=0;i<count;i++)
{
tmp[i] = s[i];
}
for(i=0;i<count;i++)
{
tmp[count+i] = s[count-1-i];
}
tmp[2 * count] = '\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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSkKewogICAgaW50IGk7CiAgICBmb3IoaT0wO3NbaV0hPSdcMCc7aSsrKTsKICAgIHJldHVybiBpOwp9CgovLyDplqLmlbDjga7kuK3jgad0bXDjgavlr77jgZfjgaZtYWxsb2PjgZfjgaYKLy8g44Gd44GT44Gr5Zue5paH44KS5Luj5YWl44GX44GmcmV0dXJu44Gn6L+U44GX44G+44GX44KH44GGCmNoYXIgKnNldFBhbGluZHJvbWUoY2hhciBzW10pCnsKICAgIGludCBpOwogICAgaW50IGNvdW50ID0gbXlTdHJsZW4ocyk7CgljaGFyICp0bXA7Cgl0bXAgPSAoY2hhciopbWFsbG9jKHNpemVvZihjaGFyKSooMipjb3VudCsxKSk7CiAgICBmb3IoaT0wO2k8Y291bnQ7aSsrKQogICAgewogICAgICAgIHRtcFtpXSA9IHNbaV07CiAgICB9CiAgICBmb3IoaT0wO2k8Y291bnQ7aSsrKQogICAgewogICAgICAgIHRtcFtjb3VudCtpXSA9IHNbY291bnQtMS1pXTsKICAgIH0KICAgIHRtcFsyICogY291bnRdID0gJ1wwJzsKICAgIHJldHVybiB0bXA7Cn0KCgovL+ODoeOCpOODs+mWouaVsOOBr+OBhOOBmOOCi+W/heimgeOBr+OBguOCiuOBvuOBm+OCkwppbnQgbWFpbigpewogICAgaW50IGk7CiAgICBjaGFyIG55dXJ5b2t1WzEwMjRdOyAvL+WFpeWKmwogICAgY2hhciAqa2FpYnVuOyAgIC8v5Zue5paH44KS5Y+X44GR5Y+W44KLCiAgICBzY2FuZigiJXMiLG55dXJ5b2t1KTsKICAgIGthaWJ1biA9IHNldFBhbGluZHJvbWUobnl1cnlva3UpOwogICAgcHJpbnRmKCIlc1xuICAtPiAlc1xuIixueXVyeW9rdSxrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0K