#include <iostream>
#include <bitset>
#include <string>
using namespace std;
int main()
{
int n = 5;
string str;
bitset<7> bits; //7位长度
bits = n;
str = bits.to_string();
cout<<str<<endl;
bitset<7> nums(str);
cout<<nums.to_ullong()<<endl;//转换成unsigned long long 类型整数
return 0;
}
C++ 十进制数转二进制字符串
最新推荐文章于 2024-02-17 18:08:20 发布