From 300c7454597beee7f0977b8b0639c45a397c89b0 Mon Sep 17 00:00:00 2001 From: flykhan Date: Tue, 20 Jun 2023 08:52:14 +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=E4=BA=A4=E6=8D=A2=E4=B8=A4=E4=B8=AA=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E5=80=BC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day6/homework/h10.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 day6/homework/h10.cpp diff --git a/day6/homework/h10.cpp b/day6/homework/h10.cpp new file mode 100644 index 0000000..917bfbe --- /dev/null +++ b/day6/homework/h10.cpp @@ -0,0 +1,21 @@ +#include +#include + +using namespace std; + +int main() +{ + int a = 1, b = 9; + cout << "a 原本二进制表示为: " << bitset<8>(a) << endl; + cout << "b 原本二进制表示为: " << bitset<8>(b) << endl; + + a = a ^ b; + cout << "a 第一次转换二进制表示为: " << bitset<8>(a) << "\t此时 a 的值为: " << int(a) << endl; + b = a ^ b; + cout << "a 第一次转换二进制表示为: " << bitset<8>(a) << "\t此时 a 的值为: " << int(a) << endl; + a = a ^ b; + cout << "a 第一次转换二进制表示为: " << bitset<8>(a) << "\t此时 a 的值为: " << int(a) << endl; + + cout << "转换后结果为: a = " << int(a) << "\tb = " << int(b) << endl; + return 0; +} \ No newline at end of file