diff --git a/day6/homework/h6.cpp b/day6/homework/h6.cpp new file mode 100644 index 0000000..306e309 --- /dev/null +++ b/day6/homework/h6.cpp @@ -0,0 +1,18 @@ +#include +#include + +using namespace std; + +int main() +{ + int input_num; + int flag; // 偶数标志 + cout << "请输入一个整数: "; + cin >> input_num; + + flag = input_num & 0x1; // 和最后一位作比较,最后一位如果是1,则为奇数 + + cout << "该数" << (!flag ? "是偶数" : "不是偶数") << endl; // 非0为真,0为假 + + return 0; +} \ No newline at end of file