二级C程序修改2
===========================================
试题说明 :
===========================================
给定程序MODI1.C中函数 fun 的功能是:将未在字符串s中出
现而在字符串t中出现的字符形成一个新的字符串放在u中,u中字
符按原字符串中字符顺序排列,不去掉重复字符。
例如,当s = "ABCDE",t = "BDFGG"时,
u中的字符串为"FGG"。
请改正函数fun中的错误,使它能得出正确的结果。注意:不
要改动main函数,不得增行或删行,也不得更改程序的结构!
===========================================
程序 :
===========================================
#include
#include
#include
void fun (char *s, char *t, char *u)
{ int i, j, sl, tl;
sl = slen(s); tl = slen(t);
/************found************/
for (i=0; i/************found************/
{ for (j=0; j if (t[i] == s[j]) break;
if (j=sl) *u = t[i];
}
/************found************/
u = '\0';
}
main()
{ char s[100], t[100], u[100];
clrscr();
printf("\nPlease enter sing s:"); scanf("%s", s);
printf("\nPlease enter sing t:"); scanf("%s", t);
fun(s, t, u);
printf("The result is: %s\n", u);
}
===========================================
所需数据 :
===========================================
#3
@1 001006
for (i=0; ifor (i=0; ifor (i=0; ifor (i=0; ifor (i=0; ifor (i=0; i@2 001006
{for (j=0; j{for (j=0; j{for (j=0; j{for (j=0; j{for (j=0; j{for (j=0; j@3 001006
*u='\0';
*u=0;
(*u)='\0';
(*u)=0;
u[0]='\0';
u[0]=0;