C语言趣味程序百例精解之JAVA实现(51)谁是窃贼
程序:
public class Test51{
public static void main(String args[]){
whoTellLie51();
}
/**
* 51.谁在说谎whoTellLie51 小偷==1
*/
public static void whoTellLie51() {
for (int a = 0; a <= 1; a++)
for (int b = 0; b <= 1; b++)
for (int c = 0; c <= 1; c++)
for (int d = 0; d <= 1; d++) {
if (a + b + c + d == 1 && (b + d == 1) && (b + c == 1)
&& (a + b == 1)) {
System.out.println("a=" + a);
System.out.println("b=" + b);
System.out.println("c=" + c);
System.out.println("d=" + d);
}
}
}
}
运行结果:
C:\bat>java Test51
a=0
b=1
c=0
d=0
C语言趣味程序百例精解之JAVA实现(51)谁是窃贼
最新推荐文章于 2022-02-25 19:38:17 发布