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