Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
147487 冯诚阳 十进制小数转二进制 C++ Wrong Answer 0 MS 276 KB 713 2026-02-05 15:49:46

Tests(1/10):


Code:

#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; int z=a; a-=z; int i=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; }


Run Info:

------Input------
0
------Answer-----
0
------Your output-----