| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 69687 | 祝家懿 | 十进制小数转二进制 | C++ | Wrong Answer | 1 MS | 272 KB | 443 | 2024-04-06 12:13:15 |
#include<bits/stdc++.h> using namespace std; int main(){ double a; cin>>a; int n=a; double z=a-n; if(a==0){ cout<<'0'; } int x[32]={0}; int cnt=0; while (n!=0){ x[cnt]=n%2; n/=2; cnt++; } for(int i=cnt-1;i>=0;i--){ cout<<x[i]; } if(x==0){ return 0; } else{ cout<<'.'; } for(int i=0;i<9;i++){ z*=2; cout<<(int)z; z-=(int)z; if(z==0){ break; } } return 0; }
------Input------
0
------Answer-----
0
------Your output-----
0.0