#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[]){
int i,size;
char *tmp;
size = myStrlen(s);
tmp
= (char *)malloc(sizeof(char)*(2*size
+1)); if(tmp == NULL){
return NULL; //void型なので何も返さず終了
}
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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSl7CiAgICBpbnQgaTsKICAgIGZvcihpPTA7c1tpXSE9J1wwJztpKyspO3sKICAgIAkKICAgIH0KICAgIHJldHVybiBpOwp9CgpjaGFyICpzZXRQYWxpbmRyb21lKGNoYXIgc1tdKXsKICAgIGludCBpLHNpemU7CiAgICBjaGFyICp0bXA7CiAgICBzaXplID0gbXlTdHJsZW4ocyk7CiAgICB0bXAgPSAoY2hhciAqKW1hbGxvYyhzaXplb2YoY2hhcikqKDIqc2l6ZSsxKSk7CiAgICBpZih0bXAgPT0gTlVMTCl7CiAgICAgICAgcHJpbnRmKCJFUlJPUlxuIik7CiAgICAgICAgcmV0dXJuIE5VTEw7IC8vdm9pZOWei+OBquOBruOBp+S9leOCgui/lOOBleOBmue1guS6hgogICAgfQogICAgZm9yKGk9MDtpPHNpemU7aSsrKXsKICAgIAl0bXBbaV0gPSBzW2ldO30KICAgIGZvcihpPTA7aTxzaXplO2krKykgIHsKICAgIAl0bXBbaStzaXplXSA9IHNbc2l6ZS1pLTFdO30KICAgIHRtcFsyKnNpemVdID0gJ1wwJzsKICAgIHJldHVybiB0bXA7Cn0KCgppbnQgbWFpbigpewogICAgaW50IGk7CiAgICBjaGFyIG55dXJ5b2t1WzEwMjRdOyAvL+WFpeWKmwogICAgY2hhciAqa2FpYnVuOyAgIC8v5Zue5paH44KS5Y+X44GR5Y+W44KLCiAgICBzY2FuZigiJXMiLG55dXJ5b2t1KTsKICAgIGthaWJ1biA9IHNldFBhbGluZHJvbWUobnl1cnlva3UpOwogICAgcHJpbnRmKCIlc1xuICAtPiAlc1xuIixueXVyeW9rdSxrYWlidW4pOwogICAgZnJlZShrYWlidW4pOwogICAgcmV0dXJuIDA7Cn0K