描述
题目:输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。
例如,输入”They are students.”和”aeiou”,
则删除之后的第一个字符串变成”Thy r stdnts.”。
格式
输入格式
输入:
They are students.
aeiou
输出格式
输出:
Thy r stdnts.
样例
样例输入
They are students.
aeiou
样例输出
Thy r stdnts.
你题目的解答代码如下:
#include <stdio.h>
int main()
{
char a[100];
char b[100];
int i,j,k=0,f=0;
gets(a);
gets(b);
for( i=0; a[i]!='\0'; i++ )
{
f=0;
for ( j = 0; b[j]!='\0'; j++)
if (b[j]==a[i])
{
f=1;
break;
}
if (f==0)
a[k++] = a[i];
}
a[k]='\0';
printf("%s", a);
return 0;
}
如有帮助,望采纳!谢谢!