谁是作案嫌疑人?

谁是作案嫌疑人?
Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description

刑侦大队对涉及六个嫌疑人的一桩疑案进行分析:
一、a ,b至少有一人作案;
二、a,e,f三人中至少有两人参与作案;
三、 a ,d不可能是同案犯;
四、b,c或同时作案,或与本案无关;
五 c,d中有且只有一人作案;
六 如果d没有参与作案则e也不可能参与作案。
试编写程序,寻找作案人。
Input

多组测试数据,对于每组测试数据,第 1 行输入 6 个空格分隔的整数,代表a、b、c 、d 、e 、f的编号,编号x范围(1 <= x <= 6),且编号互不相同。
Output

对于每组测试数据,第 1 行至第 6 行分别输出对 a、b、c 、d 、e 、f的判断,详细输出格式请参考样例。

Sample Input

1 2 3 4 5 6
Sample Output

The suspects numbered 1 are criminals.
The suspects numbered 2 are criminals.
The suspects numbered 3 are criminals.
The suspect numbered 4 is not a criminal.
The suspect numbered 5 is not a criminal.
The suspects numbered 6 are criminals.

#include <stdio.h>
#include <memory.h>
int main()
{
    int a1,b1,c1,d1,e1,f1;
    int a[7]; //每个人是否作案
    int b[7]; //每个条件是否正确
    while(scanf("%d%d%d%d%d%d",&a1,&b1,&c1,&d1,&e1,&f1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(a[a1]=0; a[a1]<=1; a[a1]++)
        {
            for(a[b1]=0; a[b1]<=1; a[b1]++)
            {
                for(a[c1]=0; a[c1]<=1; a[c1]++)
                {
                    for(a[d1]=0; a[d1]<=1; a[d1]++)
                    {
                        for(a[e1]=0; a[e1]<=1; a[e1]++)
                        {
                            for(a[f1]=0; a[f1]<=1; a[f1]++)
                            {
                                b[1]=(a[a1]||a[b1]);//a、b至少有一人作案;
                                b[2]=(a[a1]+a[e1]+a[f1]>=2);//a,e,f三人中至少有两人参与作案;
                                b[3]=(a[a1]+a[d1]<=1);//a 、d不可能是同案犯;
                                b[4]=((a[b1]+a[c1]==2)||(a[b1]+a[c1]==0));//b,c或同时作案,或与本案无关;
                                b[5]=(a[c1]+a[d1]==1);//c,d中有且只有一人作案;
                                if(a[d1]==0)//如果d没有参与作案则e也不可能参与作案。
                                {
                                    if(a[e1]==0)
                                        b[6]=1;
                                    else b[6]=0;
                                }
                                if(b[1]+b[2]+b[3]+b[4]+b[5]+b[6]==6)//在满足所有条件下
                                {
                                    if(a[a1]==1) printf("The suspects numbered %d are criminals.\n",a1);
                                    else printf("The suspect numbered %d is not a criminal.\n",a1);
                                    if(a[b1]==1) printf("The suspects numbered %d are criminals.\n",b1);
                                    else printf("The suspect numbered %d is not a criminal.\n",b1);
                                    if(a[c1]==1) printf("The suspects numbered %d are criminals.\n",c1);
                                    else printf("The suspect numbered %d is not a criminal.\n",c1);
                                    if(a[d1]==1) printf("The suspects numbered %d are criminals.\n",d1);
                                    else printf("The suspect numbered %d is not a criminal.\n",d1);
                                    if(a[e1]==1) printf("The suspects numbered %d are criminals.\n",e1);
                                    else printf("The suspect numbered %d is not a criminal.\n",e1);
                                    if(a[f1]==1) printf("The suspects numbered %d are criminals.\n",f1);
                                    else printf("The suspect numbered %d is not a criminal.\n",f1);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值