C语言编程判断输入整数x的正负性和奇偶性。 **输入格式要求:"%d" 提示信息:"Enter a integer:" **输出格式要求:"The integer is a plus even number\n" "This integer is a plus odd number\n" "This integer is a minus even number\n" "This integer is a minus odd number\n" "This integer is zero.\n" 程序运行示例如下: Enter a integer:-9 This integer is a minus odd number
时间: 2023-07-03 12:04:33 浏览: 189
下面是一个示例代码实现:
```c
#include <stdio.h>
int main() {
int x;
printf("Enter a integer:");
scanf("%d", &x);
if (x > 0) { // 正数
if (x % 2 == 0) { // 偶数
printf("This integer is a plus even number\n");
} else { // 奇数
printf("This integer is a plus odd number\n");
}
} else if (x < 0) { // 负数
if (x % 2 == 0) { // 偶数
printf("This integer is a minus even number\n");
} else { // 奇数
printf("This integer is a minus odd number\n");
}
} else { // 零
printf("This integer is zero.\n");
}
return 0;
}
```
运行结果:
```
Enter a integer:-9
This integer is a minus odd number
```
阅读全文