C语言编程,抓偷木头犯人
答案:2 悬赏:10 手机版
解决时间 2021-11-23 00:29
- 提问者网友:人生佛魔见
- 2021-11-22 03:54
C语言编程,抓偷木头犯人
最佳答案
- 五星知识达人网友:鸠书
- 2021-11-22 04:20
#include
#include
#define Truth 0
#define Lie 1
void main()
{
int a=1;
int b=1;
int c=1;
int d=1;
while(1)
{
if(a == Lie)
{
b =Truth;
c =Truth;
d =Truth;
}
if(b == Truth)
{
a = Truth;
c = Lie;
}
if(c == Truth)
{
a = Truth;
b = Lie;
d = Lie;
}
if(d == Truth)
{
a= Truth;
c = Lie;
}
if((a+b+c+d)==Lie)
{
printf("a:%d b:%d c:%d d:%d
",a,b,c,d);
if(a==1)
{
printf("A is the thief
");
break;
}
if(b==0)
{
printf("C is the thief
");
break;
}
if(c==0)
{
printf("D is the thief
");
break;
}
if(d==1)
{
printf("D is the thief
");
break;
}
printf("B is the thief
");
break;
}
}
}
#include
#define Truth 0
#define Lie 1
void main()
{
int a=1;
int b=1;
int c=1;
int d=1;
while(1)
{
if(a == Lie)
{
b =Truth;
c =Truth;
d =Truth;
}
if(b == Truth)
{
a = Truth;
c = Lie;
}
if(c == Truth)
{
a = Truth;
b = Lie;
d = Lie;
}
if(d == Truth)
{
a= Truth;
c = Lie;
}
if((a+b+c+d)==Lie)
{
printf("a:%d b:%d c:%d d:%d
",a,b,c,d);
if(a==1)
{
printf("A is the thief
");
break;
}
if(b==0)
{
printf("C is the thief
");
break;
}
if(c==0)
{
printf("D is the thief
");
break;
}
if(d==1)
{
printf("D is the thief
");
break;
}
printf("B is the thief
");
break;
}
}
}
全部回答
- 1楼网友:上分大魔王
- 2021-11-22 05:24
三个真话,一个假话,C和D说的相对,肯定在C和D中。排除法可以知道是C在说假话追问需要用C的程序编出来
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯