开心消消乐
Time Limit: 2000/1000ms (Java/Others)
Problem Description:
大白最近喜欢上了开心消消乐,于是英语基础好的他准备让课文中英语句子也来充当游戏的主角。
规则如下:输入两个字符串,从第一个字符串中删除第二个字符串所出现的字符(包括空格)
1<=字符串的长度<=1000。
Output:
若第一个字符串不能被全部消除则输出删除后的字符串(如删剩下空格则输出空格),否则输出“YES”(不包括双引号)。
每个输出占一行
Sample Input:
They are students
aeiou
Sample Output:
Thy r stdnts
解题思路:这道题用java最好不过了,前提是要了解java的正则表达式,具体什么是正则表达式就问度娘吧。
AC代码:
1 import java.util.Scanner;
2 public class Main {
3 public static void main(String[] args) {
4 Scanner scan = new Scanner(System.in);
5 while(scan.hasNext()){
6 String obj=scan.nextLine();
7 String str="["+scan.nextLine()+"]";
8 obj=obj.replaceAll(str,"");
9 if(obj.length()>0)System.out.println(obj);
10 else System.out.println("YES");
11 }
12 }
13 }