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

来源:互联网 发布:jsp中嵌入java代码 编辑:程序博客网 时间:2024/05/18 11:03

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

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:6648

解决:3017

题目描述:

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

输入:

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

输出:

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

样例输入:
healloa
样例输出:
hello
参考代码:

import java.util.Scanner;public class Main {public static void main(String arg[]){Scanner sc = new Scanner(System.in);while(sc.hasNext()){String string = sc.nextLine();String c = sc.nextLine();string = string.replace(c, "");System.out.println(string);//System.out.print(string.contains(c));}}}



0 0
原创粉丝点击