Run ID:94049
提交时间:2024-10-19 17:32:32
#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; if(x==0) cout<<0; 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; } } cout<<endl; return 0; }