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 }
  • 相关阅读:
    JSP页面
    JSP简介
    常量与变量的声明与使用
    AJAX无刷新上传图片
    JSP连接MySql数据库
    运算符与表达式
    世界级的javascript ajax client端UI库 Ext学习笔记 menu组件 和 toolbar组件
    OOD/OOA基本原则
    Java字符编码转换过程说明
    正则表达式系统教程
  • 原文地址:https://www.cnblogs.com/PureJava/p/10498089.html
Copyright © 2011-2022 走看看