编程语言
首页 > 编程语言> > C++进制转换

C++进制转换

作者:互联网

C++中,如果进行二进制转换

 

#include<iostream>
#include<bitset>
using namespace std;
#define unsigned int uint32_t
void transferRadix(int n){
    cout << "hex: " << std::hex << n << endl;
    cout << "dec: " << std::dec << n << endl;
    cout << "oct: " << std::oct << n << endl;
    cout << "binary: " << bitset<32>(n) << endl;
}

int main()
{
    int n = 10800;
    transferRadix(n);
    transferRadix(n>>8);

    return 0;
}

 

标签:std,转换,进制,int,C++,transferRadix,include
来源: https://www.cnblogs.com/wanghao-boke/p/16553604.html