akoj-1189-字符串去特定字符

来源:互联网 发布:淘宝如何设置两个客服 编辑:程序博客网 时间:2024/06/11 02:41

字符串去特定字符

Time Limit:1000MS  Memory Limit:65536K
Total Submit:42 Accepted:11

Description

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

Input

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

Output

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

Sample Input

healloa

Sample Output

hello

Source

#include<cstdio>#include<cstring>#include<iostream>using namespace std;int main(){    char s[1001],b[1001],c;    int len,i;    while(scanf("%s",s)!=EOF)    {        getchar();//不要忘了        len=strlen(s);        scanf("%c",&c);        for(i=0; i<len; i++)        {            if(s[i]==c) b[i]=0;            else b[i]=1;        }        for(i=0; i<len; i++)        {            if(b[i]==1) cout<<s[i];        }        cout<<'\n';    }    return 0;}


0 0
原创粉丝点击