-
题目描述:
-
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
-
输入:
-
测试数据有多组,每组输入字符串s和字符c。
-
输出:
-
对于每组输入,输出去除c字符后的结果。
-
样例输入:
-
heallo a
-
样例输出:
-
hello
第一种方法:
#include <iostream>
#include <string>
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)
{
cout<<s[i];
}
}
cout<<endl;
}
return 0;
}
/**************