From 1acf92d7ab50716e21843112695d78d7bdbfc6e6 Mon Sep 17 00:00:00 2001 From: flykhan Date: Tue, 20 Jun 2023 08:46:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BD=8D=E8=BF=90=E7=AE=97?= =?UTF-8?q?=E7=AC=A6=E5=AE=9E=E7=8E=B0=E4=BB=A5=E4=B8=8B=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=EF=BC=9A=E5=88=A4=E6=96=AD=E4=B8=80=E4=B8=AA=E6=95=B0=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E5=81=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day6/homework/h6.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 day6/homework/h6.cpp 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