Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
155253 陈骏睿 十进制小数转二进制 C++ Wrong Answer 1 MS 276 KB 602 2026-06-06 11:39:55

Tests(0/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(){ double b,x=0; cin>>b; int a=b,er[33]={},i=0; if(a==0)cout<<0; while(a!=0){ er[i]=a%2; a/=2; i++; } for(int j=i-1;j>=0;j--){ cout<<er[j]; } x=b-a; if(x!=0){ cout<<'.'; while(x!=0){ x*=2; cout<<int(x); x-=int(x); } } return 0; }


Run Info:

------Input------
98.69140625
------Answer-----
1100010.10110001
------Your output-----
1100010.1970110001