qfedu-basic-level/day7/homework/h13.cpp

19 lines
494 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 将一个数的二进制表示中所有的 1 都变成 0所有的 0 都变成 1
#include <iostream>
#include <bitset>
#include <climits>
using namespace std;
int main()
{
int n;
cout << "请输入一个整数: ";
cin >> n;
cout << "原本的二进制表示为: " << bitset<32>(n) << endl;
cout << "UINT_MAX 的二进制表示为: " << bitset<32>(UINT_MAX) << endl;
cout << "取反后的二进制表示为: " << bitset<32>(n ^ UINT_MAX) << endl;
return 0;
}