Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
140113 李朋秦 十进制小数转二进制 C++ Wrong Answer 0 MS 272 KB 352 2025-12-13 15:37:40

Tests(0/10):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ double a; int x[101]={},b=0; cin>>a; int i=0; if(a==0)cout<<0; b=a; while(b!=0){ x[i]=b%2; b/=2; i++; }for(int j=i-1;j>=0;j--)cout<<x[j]; double c=a-b; if(c!=0){ cout<<"."; while(c!=0){ c=c*2; cout<<int(c); c=c-(int(c)); } } return 0; }


Run Info:

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