题目1049:字符串去特定字符

题目1049:字符串去特定字符

时间限制:秒内存限制:32 

题目描述:

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

输入:

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

输出:

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

样例输入:

heallo

a

样例输出:

hello

/**************************************************************
Problem: 1049
User: watchfree
Language: Java
Result: Accepted
Time:80 ms
Memory:15424 kb
****************************************************************/
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            String str=sc.next();
            String ch=sc.next();
            System.out.println(str.replace(ch, ""));
        }
            sc.close();
    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5329148.html