| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 138483 | 冯诚阳 | 十进制小数转二进制 | C++ | Wrong Answer | 0 MS | 272 KB | 517 | 2025-11-24 20:22:07 |
#include <iostream> using namespace std; int main(){ double n; cin>>n; int a=n; double b=n-a; int x[64]={},w=0; if(n==0){ cout<<0;return 0; } while(a!=0){ x[w]=a%2; w++; a/=2; } for(int i=w-1;i>=0;i--) cout<<x[i]; if(b!=0) cout<<'.'; while(b!=0){ b*=2; if(b>=1){ cout<<1; b-=1; } else{ cout<<0; } } return 0; }
------Input------
0.125
------Answer-----
0.001
------Your output-----
.001