Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
111433 | 邹昊辰 | 十进制小数转二进制 | C++ | Wrong Answer | 0 MS | 284 KB | 422 | 2025-03-01 23:05:05 |
#include<bits/stdc++.h> using namespace std; double n; int s[64]; int main(){ cin>>n; int z=n; doublex=n-z; if(z==0){ cout<<0; } int l=0; while(z!=0){ s[l]=z%2; l++; z/=2; } for(int i=l-1;i>=0;i--){ cout<<s[i]; } if(x!=0){ cout<<"."; }else{ return 0; } for(int i=0;i<9;i++){ x=x*2; int zz=x; cout<<zz; x=x-zz; if(x==0){ break; } } return 0; }
------Input------
98.69140625
------Answer-----
1100010.10110001
------Your output-----