文章
2
粉丝
0
获赞
3
访问
73
#include<bits/stdc++.h>
using namespace std;
int div2(string &s){
int remainder = 0;
for(int i = 0 ; i < s.size() ; i++){
int current = remainder *10 + (s[i] - '0');
s[i] = current/2 + '0';
remainder = current %2;
}
while(s.size() > 1 && s[0] == '0')
s.erase(0,1);
return remainder;
}
string to_bi(string n){
string s = "";
if(n == "0") return "0";
while( n != "0"){
int bit = div2(n);
s += bit + '0';
}
return ...
登录后发布评论
暂无评论,来抢沙发