From acabbbf7140a2c1c81b6c47f7ba8d5574f2bbf21 Mon Sep 17 00:00:00 2001 From: flykhan Date: Tue, 20 Jun 2023 08:49:38 +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=B0=86=E4=B8=80=E4=B8=AA=E6=95=B0=E7=9A=84=E7=AC=AC?= =?UTF-8?q?=20n=20=E4=BD=8D=EF=BC=88=E4=BB=8E=E5=8F=B3=E5=BE=80=E5=B7=A6?= =?UTF-8?q?=E6=95=B0=EF=BC=89=E8=AE=BE=E4=B8=BA=200=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day6/homework/h3.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 day6/homework/h3.cpp diff --git a/day6/homework/h3.cpp b/day6/homework/h3.cpp new file mode 100644 index 0000000..f43367c --- /dev/null +++ b/day6/homework/h3.cpp @@ -0,0 +1,17 @@ +#include +#include + +using namespace std; + +int main() +{ + char x = 0b01011011; // char 正好是八位 + + cout << "原值为: " << bitset<8>(x) << endl; + int n; + cout << "请输入要修改的位: "; + cin >> n; + x &= ~(0x1 << n); // 作用: 将第 n 位设置为 0 + cout << "修改后为: " << bitset<8>(x) << endl; + return 0; +} \ No newline at end of file