九度 OJ 1049 字符串去特定字符

来源:互联网 发布:人工智能 中英 百度云 编辑:程序博客网 时间:2024/05/22 01:51

题目描述:


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

输入:


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

输出:


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

样例输入:


heallo
a

样例输出:


hello


***********************************************************

题目中没有给出字符串的长度,第一次写的时候,我定义为81,AC。改了几次值,均AC,直到改为1时才出现Wrong Answer。是评判系统智能判断你的长度,还是测试用例就是一个字符的字符串????


#include<stdio.h>#include<string.h> int main(){    char c;    char s[2];    int len,i;    while(EOF != scanf("%s",s))    {        getchar();        scanf("%c",&c);        len = strlen(s);        for(i = 0;i < len;i++)            if(s[i] != c)                printf("%c",s[i]);        printf("\n");    }    return 0;} /**************************************************************    Problem: 1049    User:     Language: C    Result: Accepted    Time:0 ms    Memory:912 kb****************************************************************/


0 0
原创粉丝点击