题解 | #字符串字符匹配#

字符串字符匹配

http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

public class Main {
     public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
         if(sc.hasNext()){
             String str = sc.nextLine();
             String strLong=sc.nextLine();
             char[] strChar=str.toCharArray();
             char[] LongChar=strLong.toCharArray();
             int count=0;
             for(char c:strChar){
                 for(char c1:LongChar){
                     if(c==c1){
                         count++;
                         break;
                     }
                 }
             }
             if(count==str.length()){
                 System.out.print(true);
             }else{
                 System.out.print(false);
             }
         }
     }
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务