Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
94036 | 孙嘉言 | 十进制小数转二进制 | C++ | Wrong Answer | 1 MS | 276 KB | 429 | 2024-10-19 17:21:04 |
#include <iostream> #include <cstring> #include <cmath> using namespace std; int main(){ double str; int a[1001],i=0; cin>>str; int x=str; double y=str-x; if(str==0) cout<<0; while(x!=0){ a[i]=x%2; x/=2; i++; }for(int k=i-1;k>=0;k--) cout<<a[k]; cout<<'.'; while(y!=0){ y*=2; cout<<(int)y; y-=(int)y; } return 0; }
------Input------
0
------Answer-----
0
------Your output-----
0.