主题
写出对正数、负数和零均适用的偶数判断表达式。
(x % 2) == 0
也可以封装为函数:
#include <stdbool.h> static bool is_even(int x) { return (x % 2) == 0; }
若分别代入题目给出的值:
x
0
true
1
false
2
-3