【谁去出国学习】

for p in range(2):#分别把0,1赋值给p,赵去
    for q in range(2):#分别把0,1赋值给q,钱去
        for r in range(2):#分别把0,1赋值给r,孙去
            for m in range(2):#分别把0,1赋值给m,李去
                for n in range(2):#分别把0,1赋值给n,周去
                    #分别列出1,2,3,4,5对应合式公式
                    A = ((not p)and q)or((not p)and (not q))or (p and q)
                    B = m or n
                    C = ((not r) and q) or ((not q) and r)
                    D = ((not r) and (not m)) or (r and m)
                    E = ((not n)and((not p) and q))or(n and p and q)or((not n)and (p and (not q)))or((not n)and((not p) and (not q)))or((not n)and(p and q))

                    M=A and B and C and D and E#对M进行赋值,真值为T
                    if M ==1:
                        print("%d %d,%d,%d,%d"%(p,q,r,m,n))
                        if p==1:
                            print("赵去")
                        if q==1:
                            print("钱去")
                        if r==1:
                            print("孙去")
                        if m==1:
                            print("李去")
                        if n==1:
                            print("周去")
                        
                

某公司要从赵,钱,孙,李,周五人中选人出国实习,需满足:

1,若赵去则钱也去。

2,李周两人必有一人去。

3,钱孙两人中去且只去一人。

4,孙李两人同去或同不去。

5,若周去,则赵钱也同去。

代码及详解如上。

运行结果为:

00110 孙李去

11001 赵钱周去

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值