| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 147489 | 冯诚阳 | 十进制小数转二进制 | C++ | Accepted | 0 MS | 272 KB | 798 | 2026-02-05 15:52:06 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ char b[64]; double a; cin>>a; if(a==0){ cout<<'0';return 0; } int z=a; a-=z; int i=0; if(z==0) cout<<'0'; while(z){ b[i]=char(z%2+'0'); z/=2; i++; } for(int j=i-1;j>=0;j--) cout<<b[j]; if(a>0) cout<<'.'; else return 0; while(a!=0){ a*=2; if(a>=1){ cout<<'1'; a-=1; } else { cout<<'0';} } return 0; }