21 lines
719 B
C++
21 lines
719 B
C++
#include <iostream>
|
|
#include <bitset>
|
|
|
|
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;
|
|
} |