Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
94039 孙嘉言 十进制小数转二进制 C++ Wrong Answer 0 MS 276 KB 434 2024-10-19 17:22:58

Tests(1/10):


Code:

#include <iostream> #include <cstring> #include <cmath> using namespace std; int main(){ double str; int a[1001],i=0; cin>>str; int x=str; double y=str-x; while(x!=0){ a[i]=x%2; x/=2; i++; }for(int k=i-1;k>=0;k--) cout<<a[k]; if(y!=0){ cout<<'.'; while(y!=0){ y*=2; cout<<(int)y; y-=(int)y; } } return 0; }


Run Info:

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