标签:
Description
Input
Output
Sample Input
Sample Output
#include<iostream> using namespace std; void f(double n) { int i,j,k,a[100],p=0; double t; k=n; t=n-k; if(k==0)cout<<0; while(k){ if(k%2==0)a[p++]=0; else a[p++]=1; k=k/2; } for(i=p-1;i>=0;i--)cout<<a[i]; if(t){ cout<<"."; while(1){ t*=2; if(t>=1){ cout<<1; if(t==1)break; else t-=1; } else cout<<0; } } cout<<endl; } int main() { double n; while(cin>>n){ f(n); } //system("pause"); return 0; }
标签:
原文地址:http://www.cnblogs.com/farewell-farewell/p/5186063.html