qfedu-basic-level/day4/d2.cpp

14 lines
547 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.

#include <bitset> // 用于使用bitset
#include <iostream>
using namespace std;
int main()
{
cout << "12 = " << 12 << endl; // 结果: 12
cout << "ob01001 = " << bitset<5>(0b01001) << endl; // 结果: 9, bitset<8>用于2进制形式输出
cout << "062 = " << 062 << endl; // 结果: 50
cout << "062 = " << oct << 062 << endl; // 结果: 50, oct 用于8进制形式输出
cout << "0x4f = " << hex << 0x4f << endl; // 结果: 79hex 用于16进制形式输出
}