分页:
上一页 1 [2] 3 4 5 6 7 8 9 下一页
请改正函数fun中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
Modi1.c
#include
#include
#include
void fun (char *s, char *t)
{ int i, sl;
sl = strlen(s);
/************found************/
for (i=1; i { t[2*i] = s[sl-i-1];
t[2*i +1] = s[sl-i-1];
}
/************found************/
t[2*sl] = ’0/’; /参考答案:t[2*sl] = ’\0’;/
}
main()
{ char s[100], t[100];
clrscr();
printf("\nPlease enter string s:"); scanf("%s", s);
fun(s, t);
printf("The result is: %s\n", t);
}
第3题
给定程序MODI1.C中函数 fun 的功能是:将在字符串s中下标为偶数位置上的字符,紧随其后重复出现一次,放在一个新串t中,t中字符按原字符串中字符的顺序排列。(注意0为偶数)
例如:当s中的字符串为:"ABCDE"时,
则t中的字符串应为:"AACCEE"。
请改正函数fun中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
Modi1.c
#include
#include
#include
void fun (char *s, char *t)
{ int i, j, sl;
sl = strlen(s);
/************found************/
for (i=0, j=0; i { t[2*j] = s[i];
分页:
上一页 1 [2] 3 4 5 6 7 8 9 下一页