Run ID:69673
提交时间:2024-04-06 12:01:33
#include<bits/stdc++.h> using namespace std; int main(){ int n,i=0,s[32]={0}; double x; cin>>x; n=x; if(n==0){ cout<<0; } while(n!=0){ s[i++]=n%2; n=n/2; } for(int j=i-1;j>=0;j--){ cout<<s[j]; } x=x-n; if(x!=0){ cout<<"."; for(int j=0;j<9;j++){ x=x*2; cout<<int(x); x-=int(x); if(x==0){ break; } } } return 0; }