文章

8

粉丝

0

获赞

44

访问

2.0k

头像
十进制和二进制 题解:
P1176 清华大学上机题
发布于2025年3月13日 21:50
阅读数 309

#include <bits/stdc++.h>
using namespace std;
string tentotwo(string a)
{
    string ans="";//二进制翻转
    while(a!="0")
    {
        string c="";//商
        int carry=0;
        for(int i=0;i<a.size();i++)
        {
            int temp=carry*10+(a[i]-'0');
            carry=temp%2;
            c+=(temp/2+'0');
        }
        ans+=(carry+'0');
        while(c.size()>1&&c[0]=='0')
        {
            c.erase(0,1);
 &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发