题目1049:字符串去特定字符
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:9683
解决:4384
-
题目描述:
-
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
-
输入:
-
测试数据有多组,每组输入字符串s和字符c。
-
输出:
-
对于每组输入,输出去除c字符后的结果。
-
样例输入:
-
heallo a
-
样例输出:
-
hello
-
来源:
字符串输入时尽量使用C++格式cin输入
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
string s;
while(cin>>s){
char c;
cin>>c;
for(int i=0;i<s.length();i++){
if(s[i]!=c) {
printf("%c",s[i]);
}
}
printf("\n");
}
}
/**************************************************************
Problem: 1049
User: th是个小屁孩
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/