题目描述
输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。例如,输入”They are students.”和”aeiou”,则删除之后的第一个字符串变成”Thy r stdnts.”
输入描述:
每个测试输入包含2个字符串
输出描述:
输出删除后的字符串
示例1
输入
They are students. aeiou
输出
Thy r stdnts.
import java.util.*;
public class wzww{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String x=sc.nextLine();
String y=sc.nextLine();
rev(x,y);
}
public static String rev(String x,String y){
for(int i=0;i<x.length();i++){
for(int j=0;j<y.length();j++){
if(x.charAt(i)==y.charAt(j)){
x=rev2(x,i);
}
}
}
System.out.print(x+"\n");
return x;
}
public static String rev2(String x,int i){
return x.substring(0,i)+x.substring(i+1);
}
}