#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 m = myStrlen(s);
tmp
= (char *)malloc(1*((m
*2)+1)); if(tmp == NULL){
return 0;
}
for(int i=0; i<m; i++)
tmp[i]=s[i];
int k=m-1;
for(int j=m; j<m*2; j++){
tmp[j]=s[k];
k--;
}
tmp[m*2]='\0';
return tmp;
}
//メイン関数はいじる必要はありません
int main(){
int i;
char nyuryoku[1024];
char *kaibun;
kaibun = setPalindrome(nyuryoku);
printf("%s\n -> %s\n",nyuryoku
,kaibun
); return 0;
}
CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3RkbGliLmg+CiAKaW50IG15U3RybGVuKGNoYXIgc1tdKXsKICAgIGludCBpOwogICAgZm9yKGk9MDtzW2ldIT0nXDAnO2krKyk7CiAgICByZXR1cm4gaTsKfQogCi8vIOmWouaVsOOBruS4reOBp3RtcOOBq+WvvuOBl+OBpm1hbGxvY+OBl+OBpgovLyDjgZ3jgZPjgavlm57mlofjgpLku6PlhaXjgZfjgaZyZXR1cm7jgafov5TjgZfjgb7jgZfjgofjgYYKY2hhciAqc2V0UGFsaW5kcm9tZShjaGFyIHNbXSl7CgljaGFyICp0bXA7CglpbnQgbSA9IG15U3RybGVuKHMpOwoKICAgIHRtcCA9IChjaGFyICopbWFsbG9jKDEqKChtKjIpKzEpKTsKICAgICAgICBpZih0bXAgPT0gTlVMTCl7CiAgICAgICAgICAgIHByaW50ZigiRVJST1JcbiIpOwogICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CgogICAgZm9yKGludCBpPTA7IGk8bTsgaSsrKQogICAgICAgIHRtcFtpXT1zW2ldOwppbnQgaz1tLTE7CiAgICBmb3IoaW50IGo9bTsgajxtKjI7IGorKyl7IAogICAgICAgIHRtcFtqXT1zW2tdOwogICAgICAgIGstLTsKICAgIH0KdG1wW20qMl09J1wwJzsKICAgIHJldHVybiB0bXA7Cn0KIAogCi8v44Oh44Kk44Oz6Zai5pWw44Gv44GE44GY44KL5b+F6KaB44Gv44GC44KK44G+44Gb44KTCmludCBtYWluKCl7CiAgICBpbnQgaTsKICAgIGNoYXIgbnl1cnlva3VbMTAyNF07CiAgICBjaGFyICprYWlidW47CiAgICBzY2FuZigiJXMiLG55dXJ5b2t1KTsKICAgIGthaWJ1biA9IHNldFBhbGluZHJvbWUobnl1cnlva3UpOwogICAgcHJpbnRmKCIlc1xuICAtPiAlc1xuIixueXVyeW9rdSxrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0=