Run ID:67427

提交时间:2024-03-16 15:29:25

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