公司派人去摸鱼,赵钱孙李周五个好兄弟在以下条件下得以派遣,求公司派遣策略 1.若赵去,则钱去 2.李、周必有一人去 3.钱、孙两人去且只去一个 4.孙李两人一起去或都不去 5.若周去,则赵钱也跟去
异或:^ 同或:~? ? (放在中间) 取反:~? ? ? (放在前面) 实践论:【i>=0】在for循环中可以写成【~i】,因为-1补码1111,取反=0就跳出
#include <iostream>
#include <stdio.h>
using namespace std;
void show(int a, int b, int c, int d, int e)
{
int t, t1, t2, t3, t4, t5;
t1 = !a | b;
t2 = d | e;
t3 = (b & !c) | (!b & c);
t4 = (c & d) | (!c & !d);
t5 = !e | (a & b);
t = t1 & t2 & t3 & t4 & t5;
printf("%d %d %d %d %d %d\n", a, b, c, d, e, t);
}
int main()
{
int p, q;
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++)
for (int e = 0; e <= 1; e++)
show(a, b, c, d, e);
return 0;
}
|