题目1049:字符串去特定字符

来源:互联网 发布:手机淘宝直通车在哪 编辑:程序博客网 时间:2024/05/18 09:41

1 秒

内存限制:32 兆

特殊判题:

提交:11443

解决:5220

题目描述:

输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。

输入:

测试数据有多组,每组输入字符串s和字符c。

输出:

对于每组输入,输出去除c字符后的结果。

样例输入:
healloa
样例输出:
hello
#include<iostream>#include<cstdio>#include<cstring> using namespace std;int main(){char str[1024];while(~scanf("%s",str)){getchar();char c;c=getchar();for(int i=0;i<strlen(str);i++){if(str[i]!=c){printf("%c",str[i]);}}cout<<endl;}return 0;}