文章
34
粉丝
18
获赞
6
访问
16.0k
#include <iostream>
#include <string.h>
#include <algorithm>
#include <string>
using namespace std;
string convert(string s,int m,int b){
string ans = "";
for(int i = 0;i < s.size();){
int k = 0;
for(int j = i;j < s.size();j ++){
int t = (k * m + s[j] - '0') % b;
s[j] = (k * m + s[j] - '0') / b + '0';
k = t;
}
ans += (k + '0');
while(s[i] == '0')i ++;
}
return ans;
}
int main(){
string s,ans;
while(cin >> s){
ans = convert(s,10,2);
reverse(ans.begin(),ans.end());
cout << ans << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发