例题:请补充fun函数,该函数的功能是:先将在字符串str中的字符串按 逆序存放在t 中,然后把str中的字符按正序连接到t的后面。
例如,str中的字符串为abc时,则t中的字符串应为cbaabc。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
代码如下:
#include<conio.h>
#include<stdio.h>
#include<string.h>
void fun(char*str,char*t)
{
int n,i;
n=strlen(str);
for(i=0;i<n;i++)
t[i]=str[n-i-1];
for(i=0;i<n;i++)
t[n+i]=str[i];
t[2*n]='\0';
}
main()
{
char str[100],t[100];
printf("\nPlease enter string:");
scanf("%s",str);
fun(str,t);
printf("The result is:%s\n",t);
}
输出运行窗口如下:
越努力越幸运!
加油,奥力给!!!