Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3846 | 吴奕希 | 十进制小数转二进制 | C++ | Wrong Answer | 0 MS | 264 KB | 419 | 2024-07-13 18:28:16 |
# include<iostream> using namespace std; int a; double b; string s1, s2; int main(){ cin>>b; a=b; while(a>0){ s1 += char(a%2+48); a /= 2; } s1 += '.'; for(int i = 0; i < 9&&b-int(b)!=0.0; i++){ b = b-int(b); b*=2; s2 = char(int(b)+48)+s2; } while(s2[s2.size()-1]=='0')s2.erase(s2.size()-1, 1); cout<<s1+s2; return 0; }
------Input------
0
------Answer-----
0
------Your output-----
.