Codeup100000580问题 E: 字符串去特定字符
问题描述:
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
输入:
测试数据有多组,每组输入字符串s和字符c。
输出:
对于每组输入,输出去除c字符后的结果。
样例输入:
goaod
a
样例输出:
good
实现代码:
#include <cstdio>
#include <cstring>
int main()
{
char s[2000];
char a;
while(gets(s)&&scanf("%c",&a)!=EOF){
int i=0;
int j=0;
while(s[i]!='\0'){
if(s[i]!=a){
printf("%c",s[i]);
}
i++;
}
printf("\n");
getchar();
}
return 0;
}