| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 62912 | 申明智 | 十进制小数转二进制 | C++ | Accepted | 2 MS | 272 KB | 500 | 2023-12-30 15:38:42 |
#include <bits/stdc++.h>. using namespace std; int main () { double num; cin>>num; if(num==0) { cout<<0; return 0; } int z=num; if(z==0) cout<<0; double x=num-z; int yu[32]; int len=0; while(z!=0) { yu[len++]=z%2; z/=2; } for(int i=len-1; i>=0; i--) { cout<<yu[i]; } if(x==0) { return 0; } else { cout<<"."; } for(int i=0; i<9; i++) { x*=2; int xz=x; cout<<xz; x-=xz; if(x==0) { break; } } return 0; }