假设张被盗,公安局派出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; } } }