#include<iostream>
#include<string>
//#include<bitset>
using namespace std;
string str="";
int BinToInt(string str)
{
int n = 0;
for (int i = 0; i < str.size(); i++)
{
n = n * 2 + (str[i] - '0');
}
return (int)n;
}
string IntToBin(int val)
{
for (int i = 16; i >= 0; i--)
{
if (val & (1 << i))//&按位计算
str += "1";
else
str += "0";
}
return str;
}
c++整型与二进制的相互转化
最新推荐文章于 2024-07-19 15:09:43 发布