码迷,mamicode.com
首页 > 其他好文 > 详细

关于谁来参加会议这个题目的卫条件

时间:2016-06-20 12:51:33      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

package cn.hncu.day7;

public class Meeting2 {

public static void main(String[] args) {
for(int a1=1;a1<=2;a1++){//1代表去,2代表不去
for(int a2=1;a2<=2;a2++){
for(int a3=1;a3<=2;a3++){
for(int a4=1;a4<=2;a4++){
for(int a5=1;a5<=2;a5++){
for(int a6=1;a6<=2;a6++){
if(tm(a1,a2,a3,a4,a5,a6)){
System.out.println("a1="+a1+",a2="+a2+",a3="
+a3+",a4="+a4+",a5="+a5+",a6="+a6);
}
}
}
}
}
}
}
}
private static int countGo(int...as){//统计有几个人去
int sum=0;
for(int a:as){
if(a==1){
sum++;
}
}
return sum;
}

public static boolean tm(int a1,int a2,int a3,int a4,int a5,int a6){
if(!(countGo(a1,a2)>=1)){//条件1的卫兵
return false;
}
if(!(countGo(a1,a5,a6)==2)){//条件2的卫兵
return false;
}
if(countGo(a2,a3)==1){//条件3的卫兵
return false;
}
if(!(countGo(a1,a4)==1)){//条件4的卫兵
return false;
}
if(!(countGo(a3,a4)==1)){//条件5的卫兵
return false;
}
if(a4==2&&a5==1){//条件6的卫兵
return false;
}

return true;
}
}

关于谁来参加会议这个题目的卫条件

标签:

原文地址:http://www.cnblogs.com/1314wamm/p/5600188.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!