zoukankan      html  css  js  c++  java
  • [PAT] 1050 String Subtraction (20 分)Java

    Given two strings S1​​ and S2​​, S=S1​​S2​​ is defined to be the remaining string after taking all the characters in S2​​ from S1​​. Your task is simply to calculate S1​​S2​​ for any given strings. However, it might not be that simple to do it fast.

    Input Specification:

    Each input file contains one test case. Each case consists of two lines which gives S1​​ and S2​​, respectively. The string lengths of both strings are no more than 104​​. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.

    Output Specification:

    For each test case, print S1​​S2​​ in one line.

    Sample Input:

    They are students.
    aeiou
    

    Sample Output:

    Thy r stdnts.
     1 package pattest;
     2 
     3 import java.io.BufferedReader;
     4 import java.io.IOException;
     5 import java.io.InputStreamReader;
     6 
     7 /**
     8  * @Auther: Xingzheng Wang
     9  * @Date: 2019/2/23 15:50
    10  * @Description: pattest
    11  * @Version: 1.0
    12  */
    13 public class PAT1050 {
    14     public static void main(String[] args) throws IOException {
    15         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    16         String s1 = reader.readLine();
    17         String s2 = reader.readLine();
    18         char[] ch = s2.toCharArray();
    19         for (char c : ch){
    20             s1 = s1.replaceAll(String.valueOf(c),"" );
    21         }
    22         System.out.print(s1);
    23     }
    24 }
  • 相关阅读:
    kubernetes上安装MongoDB-3.6.5集群副本集方式
    kubernetes Metrics-server 安装
    kubenetes 应用更新
    filebeat+logstash通过zabbix微信报警
    Redis持久化及复制
    kubernetes rabbitmq 集群安装配置
    kubernetes elasticsearch2.4 集群安装
    kubernetes --> kube-dns 安装
    详解Javascript中的Object对象
    提高代码质量:如何编写函数
  • 原文地址:https://www.cnblogs.com/PureJava/p/10498089.html
Copyright © 2011-2022 走看看