有一个字符串String str="qeirqndfadsrweqewrqewr",从键盘输入任意多个字符,例如输入:a b e,判断str中是否完全包含a b e三个字符(即字符串中既要包含a,也要包含b,还要包含e),如果完全包含,输出success,否则输出failed
//jdk1.6.0.12下编译通过
package proc;
import java.util.Scanner;
public class ScanerChar {
private static final String str="qeirqndfadsrweqewrqewr";
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String ss = scanner.nextLine();
int flag = 0;
int strvoid = 0;
for(int i = 0;i < ss.length();i++){
char c = ss.charAt(i);
if(str.indexOf(String.valueOf(c).toLowerCase()) != -1 ){
flag++;
}
if (" ".equals(String.valueOf(c).toLowerCase())){
strvoid++;
}
}
System.out.println("flag="+flag);
System.out.println("strvoid="+strvoid);
if(flag+strvoid == ss.length()){
System.out.println("SUCCESS");
}else{
System.out.println("FAIL");
}
}
}