HWOJ字符串匹配

2017-02-18  本文已影响0人  Yuu_CX
import java.util.*;
public class Main{
    public static void main(String[] args) { 
        Scanner sc = new Scanner(System.in); 
        while(sc.hasNext()){
            boolean b = boolIsAllCharExist(sc.nextLine(),sc.nextLine());
            System.out.println(b);
        }
        sc.close(); 
    } 
    public static boolean boolIsAllCharExist(String s1, String s2){
        boolean b = false;
        char temp;
        for(int i=0;i<s1.length();i++){
            temp = s1.charAt(i);
            for(int j=0;j<s2.length();j++){
                if(temp==s2.charAt(j)){
                    b = true;
                    break;
                }
            }
            if(!b) {
                return false;
            }
        }
        return true;
    }
}
上一篇下一篇

猜你喜欢

热点阅读