| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 69673 | 李琥博 | 十进制小数转二进制 | C++ | Wrong Answer | 1 MS | 268 KB | 380 | 2024-04-06 12:01:33 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,i=0,s[32]={0}; double x; cin>>x; n=x; if(n==0){ cout<<0; } while(n!=0){ s[i++]=n%2; n=n/2; } for(int j=i-1;j>=0;j--){ cout<<s[j]; } x=x-n; if(x!=0){ cout<<"."; for(int j=0;j<9;j++){ x=x*2; cout<<int(x); x-=int(x); if(x==0){ break; } } } return 0; }
------Input------
98.69140625
------Answer-----
1100010.10110001
------Your output-----
1100010.1970110001