Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
122415 Kevin 十进制小数转二进制 C++ Wrong Answer 1 MS 272 KB 474 2025-06-18 15:25:54

Tests(1/10):


Code:

#include<iostream> #include<cstring> #include<cmath> using namespace std; int main(){ double n; cin>>n; int z; double x; z=n; x=n-z; char a[64]; if(n==0) cout<<0; int i=0; while(z!=0){ a[i]=z%2+'0'; z/=2; i++; } a[i]='.'; int j=i+1; while(x>0){ a[j]=(int(x*2)+'0'); x=(x*2-int(x*2)); j++; } for(int q=i-1;q>=0;q--){ cout<<a[q]-'0'; } cout<<a[i]; for(int q=i+1;q<j;q++){ cout<<a[q]-'0'; } return 0; }


Run Info:

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