给定程序的功能是将未在字符串s中出现,而在字符串t中出现的字符,形成一个新的字符串放在u中,u中字符按原来字符串中字符顺序排序,但去掉重复的字符。
例如:当s=”12345”,t=”24677”时,u中的字符为:”67”。
请勿改动主函数main和其他函数中任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
#include
#include
void fun (char *s, char *t, char *u)
{
int i, j, sl, tl, k, ul = 0;
sl = strlen(s);
tl = strlen(t);
for (i=0; i
{
for (j=0; j
if (t[i] == s[j])
break;
if (j >= sl)
{
for (k=0; k
___1___;
if (k >= ul)
u[ul++] = ___2___;
}
}
___3___ = '\0';
}
main()
{
char s[100], t[100], u[100];
printf("\nPlease enter string s:");
scanf("%s", s);
printf("\nPlease enter string t:");
scanf("%s", t);
fun(s, t, u);
printf("The result is: %s\n", u);
}
答案:
1、break
2、t[i]
3、u[ul]
编辑特别推荐: