蓝桥杯 ALGO-89 算法训练 字符删除

xiaoxiao2021-02-28  80

问题描述   编写一个程序,先输入一个字符串str(长度不超过20),再输入单独的一个字符ch,然后程序会把字符串str当中出现的所有的ch字符都删掉,从而得到一个新的字符串str2,然后把这个字符串打印出来。   输入格式:输入有两行,第一行是一个字符串(内部没有空格),第二行是一个字符。   输出格式:经过处理以后的字符串。 输入输出样例 样例输入 123-45-678 - 样例输出

12345678

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); String str2 = in.nextLine(); str = str.replaceAll(str2, ""); System.out.println(str); in.close(); } }

转载请注明原文地址: https://www.6miu.com/read-62543.html

最新回复(0)