字符串多组测试数据,每次输出要加getchar()

http://codeup.hustoj.com/problem.php?cid=100000580&pid=4

问题 E: 字符串去特定字符

[命题人 : 外部导入]

时间限制 : 1.000 sec  内存限制 : 32 MB
 

题目描述

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

输入

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

输出

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

样例输入 Copy

goaod
a

样例输出 Copy

good
#include<bits/stdc++.h>
using namespace std;
int main(){
    char str[10005],c;
    while(gets(str)!=NULL){
        scanf("%c",&c);
        for(int i=0;i<strlen(str);i++)
            if(str[i]!=c)
                printf("%c",str[i]);
        printf("\n");
        getchar();//!!!!
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ur_ytii/article/details/112349710