zoukankan      html  css  js  c++  java
  • 张被盗

    假设张被盗,公安局派出5个人去调查,案情分析时,侦探A说:“赵与钱中至少有一个人作案”;侦探B说:“钱与孙重至少有一个人作案”;

    侦探C说:“孙与李中至少有一个人作案”;侦探D说:“赵与孙中至少有有个人与此案无关”;侦探D说:“钱与李中至少有一个人与此案无关”

    如果这5个侦探员的话都是可信的,则谁是盗窃犯

    public class Main {
        static String str[]={"1","赵","钱","孙","李"};
        static int[]a=new int[5];
        static boolean A(){
            if(a[1]==1 || a[2]==1)return true;
                return false;
        }
        static boolean B(){
            if(a[2]==1 || a[3]==1) return true;
            return false;
            
        }
        static boolean C(){
            if(a[3]==1 || a[4]==1) return true;
            return false;
        }
        static boolean D(){
            if(a[1]==0 || a[3]==0) return true;
            return false;
        }
        static boolean E(){
            if(a[2]==0 || a[4]==0) return true;
            return false;
        }
        
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            
            int i,x=0;
            for(i=1;i<=4;i++){
                a[i]=1;
                if(A())x++;
                if(B())x++;
                if(C())x++;
                if(D())x++;
                if(E())x++;
                if(x>=4)System.out.println(str[i]);
                a[i]=0;
                 x=0;
                
            }
    
        }
    
    }
  • 相关阅读:
    HTMLElement.dataset
    toLocaleString
    export,import ,export default是什么
    css鼠标禁用
    npm ERR! cb() never called! npm ERR! This is an error with npm itself.错误解决办法
    vue3的新特性
    el-dialog开启拖拽功能
    yarn config get registry
    JS中的函数防抖
    注入攻击的解决思路
  • 原文地址:https://www.cnblogs.com/watchfree/p/5330109.html
Copyright © 2011-2022 走看看