https://www.luogu.com.cn/problem/P5710
#include<iostream>
using namespace std;
bool b[5];
bool ev(int n)
{
if(n%2)
return false;
else
return true;
}
bool bi(int n)
{
if(n>4&&n<=12)
return 1;
else
return 0;
}
int main()
{
int x;
cin >> x;
b[1] = ev(x)&&bi(x);
b[2] = ev(x)||bi(x);
b[3] = (!ev(x)&&bi(x))||(ev(x)&&!bi(x));
b[4] = !ev(x)&&!bi(x);
for(int i = 1;i <= 4;i++)
{
cout << b[i] << " ";
}
}
- 这是一道训练逻辑表达的C++题目
大佬
不使用函数更加简洁
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int x;
bool a, b;
int main(){
scanf("%d", &x);
a = !(x & 1), b = (x > 4 && x <= 12);//a满足性质1,b满足性质2
printf("%d %d %d %d", a & b, a | b, (a && !b || b && !a), !a && !b);
//按条件输出就好啦QWQ
}