#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int n;
string str;
while(cin >> n)
{
if(n == 0)
cout << 0 << endl;
else
{
for(int x = n; x; x/=2)
{
if(x%2 == 0)
str += '0';
else
str += '1';
}
reverse(str.begin(), str.end());
cout << str << endl;
}
str.clear();
}
return 0;
}
十进制转化为二进制
最新推荐文章于 2024-01-14 16:54:00 发布