c++跪求答案

2024-11-19 21:43:49
推荐回答(1个)
回答1:

char *rerstr(char *str,char *des)
{
char *t=des,*p=str;
int i= -1;
while( (*des++ = *str++) )
++i;
--des;
while(*des++ = *(p+i) , i-- != -1 );
*(des-1) = 0;
return t;
}

char *rerstr_2(char str[],char des[])
{
int i=0,j;
for( ; str[i];++i)
des[i] = str[i];
for(j=i-1;j!=-1;--j,++i)
des[i] = str[j];
des[i] = 0;
return des;
}

int main()
{
char a[]="abcef";
char b[20];
printf("%s\n",rerstr(a,b));
printf("%s\n",rerstr_2(a,b));
return 0;
}

大概就这样吧。。你自己改改好了