From ce8fa14892d5e051d4738d4df57906d7ea1a658f Mon Sep 17 00:00:00 2001 From: flykhan Date: Mon, 19 Jun 2023 15:14:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E4=B8=8E&&=E4=BD=8D=E6=88=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day6/d6.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 day6/d6.cpp diff --git a/day6/d6.cpp b/day6/d6.cpp new file mode 100644 index 0000000..0dbcce9 --- /dev/null +++ b/day6/d6.cpp @@ -0,0 +1,26 @@ +#include + +using namespace std; + +int main() +{ + // 定义 Linux 的文件权限 + int r = 4, w = 2, x = 1; + int n = 0; + + // 为 n 值添加 r 和 w 权限 + n = r | w; // 6: | 位或运算符 + cout << "n = " << n << endl; // 6 + + // 为 n 值添加 x 权限 + n |= x; // 7 + cout << "n = " << n << endl; // 7 + + // 验证 n 是否包含 w 权限 + if (n & w == w) // 7 & 2 == 2: & 位与运算符 + { + cout << "n 包含 w 权限" << endl; + } + + return 0; +} \ No newline at end of file