下载:计算机等级二级C语言上机改错题题型
文章作者 100test 发表时间 2007:05:18 11:12:41
来源 100Test.Com百考试题网
给定程序MODI1.C中函数 fun 的功能是:把在字符串s中出现的每个字符,紧随其后重复出现一次,形成一个新串放在t中,t中字符按原字符串中字符顺序排列。
例如:当s中的字符串为:"ABAABBCCDDEE"。
则t中的字符串应为:"AABBCCDDEE"。
请改正函数fun中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
Modi1.c
#include
#include
#include
/************found************/
void fun (char s,char t) /参考答案:void fun (char *s,char *t)/
{ int i, sl.
sl = strlen(s).
for (i=0. i
{ t[2*i] = s[i].
t[2*i 1] = s[i].
}
/************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).
}