用c语言判断输入的三个整数中是否有两个偶数一个奇数,若是输出yes不是输出no
时间: 2023-05-25 17:06:24 浏览: 159
```c
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if ((a % 2 == 0 && b % 2 == 0 && c % 2 != 0) ||
(a % 2 == 0 && b % 2 != 0 && c % 2 == 0) ||
(a % 2 != 0 && b % 2 == 0 && c % 2 == 0)) {
printf("yes\n");
} else {
printf("no\n");
}
return 0;
}
```
或者:
```c
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int even_count = 0, odd_count = 0;
if (a % 2 == 0) {
even_count++;
} else {
odd_count++;
}
if (b % 2 == 0) {
even_count++;
} else {
odd_count++;
}
if (c % 2 == 0) {
even_count++;
} else {
odd_count++;
}
if (even_count == 2 && odd_count == 1) {
printf("yes\n");
} else {
printf("no\n");
}
return 0;
}
```
阅读全文
相关推荐















