标签:object imp size public port length oar code get
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner sc=new Scanner(System.in); String bad=sc.next(); String right=sc.next(); ArrayList list=new ArrayList(); //将不等于坏键的字符存入list当中 for (int i=0;i<right.length();i++){ for (int j=0;j<bad.length();j++){ if (right.charAt(i)==bad.charAt(j)||right.charAt(i)==bad.charAt(j)+32){ break; } else if (j==bad.length()-1){ list.add(right.charAt(i)); } } } //暂时还不能将list转换成数组,因为这个list中元素可能因为+存在必须把大写字母去掉 for (int i=0;i<list.size();i++){ for (int j=0;j<bad.length();j++){ if (bad.charAt(j)==‘+‘){ if ((char)list.get(i)>=‘A‘&&(char)list.get(i)<=‘Z‘){ list.remove(i); } } } } Object[] o=list.toArray(); char[] out=new char[o.length]; for (int i=0;i<o.length;i++){ out[i]=(char)o[i]; } //如果坏键当中存在+,那么将out当中存在的大写字母改成小写,如果没有+存在的话,直接输出out for (int j=0;j<bad.length();j++){ if (bad.charAt(j)==‘+‘){ for (int i=0;i<out.length;i++){ if (out[i]>=‘A‘&&out[i]<=‘Z‘){ out[i]=(char)(out[i]+32); } } } } if (out.length==0){ System.out.println(); } else{ for (int i=0;i<out.length;i++){ System.out.print(out[i]); } } } }
标签:object imp size public port length oar code get
原文地址:https://www.cnblogs.com/zhuzehua/p/9803225.html