问题
题目描述
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
输入
测试数据有多组,每组输入字符串s和字符c。
输出
对于每组输入,输出去除c字符后的结果。
样例输入
heallo
a
样例输出
hello
提示
不会出现s是全由c组成的字符串
代码如下:
#include <stdio.h>
#include <string.h>
int main()
{
char str[100],ch;
int len,i=0;
while(scanf("%s\n%c",str,&ch)!=EOF)
{
len=strlen(str);
for(i=0;i<len;i++)
{
if(str[i]!=ch)
{
printf("%c",str[i]);
}
}
printf("\n");
}
return 0;
}
总结
最初少了换行,结果错误50%,注意