美文网首页
HWOJ字符串匹配

HWOJ字符串匹配

作者: Yuu_CX | 来源:发表于2017-02-18 11:15 被阅读0次
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;
    }
}

相关文章

网友评论

      本文标题:HWOJ字符串匹配

      本文链接:https://www.haomeiwen.com/subject/iwprwttx.html