酷代码 AI
菜单
服务商

整数性质判断:小A、小B、小C、小D谁会喜欢这个数?

```cpp #include <iostream> using namespace std; int main() { int x; cin >> x; // 判断是否满足性质1(是偶数) bool property1 = (x % 2 == 0); // 判断是否满足性质2(大于4且不大于10) bool property2 = (x > 4 && x <= 10); // 小A喜欢两个性质同时成立的整数 int a = (property1 && property2)? 1 : 0; // 小B喜欢至少符合其中一种性质的整数 int b = (property1 || property2)? 1 : 0; // 小C喜欢刚好有符合其中一个性质的整数 int c = ((property1 &&!property2) || (!property1 && property2))? 1 : 0; // 小D喜欢不符合这两个性质的整数 int d = (!property1 &&!property2)? 1 : 0; cout << a << " " << b << " " << c << " " << d; return 0; } ``` ######[AI问答 | 259点数解答 | 2026-02-01 11:47:07]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]