1049.字符串去特定字符

题目描述:

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

输入:

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

输出:

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

样例输入:
heallo
a
样例输出:
hello

#include<iostream>
#include<cstring>
using namespace std;

int main(){
    char s[10000],a;
    while(gets(s)){
        cin>>a;
        for(int i=0;i<strlen(s);i++){
              if(s[i]!=a) cout<<s[i];
        }
        gets(s);  //冲掉空格!!!!  cin,scanf都不吃空格!!! 
        cout<<endl;
    }
    return 0;
}

 

posted @ 2018-10-01 18:04  bernieloveslife  阅读(249)  评论(0编辑  收藏  举报