#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 len=myStrlen(s);
int i,j;
char *tmp
=(char *)malloc(2*len
+1); if(tmp==NULL)
{
return NULL;
}
for(i=0;i<len;i++)
{
tmp[i]=s[i];
}
j=0;
for(i=len-1;i>=0;i--)
{
tmp[len+j]=s[i];
j++;
}
tmp[2*len]='\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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBteVN0cmxlbihjaGFyIHNbXSkKewoJaW50IGk7Cglmb3IoaT0wO3NbaV0hPSdcMCc7aSsrKTsKCXJldHVybiBpOwp9CgpjaGFyICpzZXRQYWxpbmRyb21lKGNoYXIgc1tdKQp7CglpbnQgbGVuPW15U3RybGVuKHMpOwoJaW50IGksajsKCWNoYXIgKnRtcD0oY2hhciAqKW1hbGxvYygyKmxlbisxKTsKCWlmKHRtcD09TlVMTCkKCXsKCQlyZXR1cm4gTlVMTDsKCX0KCWZvcihpPTA7aTxsZW47aSsrKQoJewoJCXRtcFtpXT1zW2ldOwoJfQoJaj0wOwoJZm9yKGk9bGVuLTE7aT49MDtpLS0pCgl7CgkJdG1wW2xlbitqXT1zW2ldOwoJCWorKzsKCX0KCXRtcFsyKmxlbl09J1wwJzsKCXJldHVybiB0bXA7CgkKfQppbnQgbWFpbigpewogICAgaW50IGk7CiAgICBjaGFyIG55dXJ5b2t1WzEwMjRdOwogICAgY2hhciAqa2FpYnVuOwogICAgc2NhbmYoIiVzIixueXVyeW9rdSk7CiAgICBrYWlidW4gPSBzZXRQYWxpbmRyb21lKG55dXJ5b2t1KTsKICAgIHByaW50ZigiJXNcbiAgLT4gJXNcbiIsbnl1cnlva3Usa2FpYnVuKTsKICAgIGZyZWUoa2FpYnVuKTsKICAgIHJldHVybiAwOwp9Cg==