Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
138485 郝王骏程 十进制小数转二进制 C++ Accepted 0 MS 272 KB 657 2025-11-24 20:25:27

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; double s; int a[64]; int main(){ cin>>s; int z=s; double x=s-z; if(z==0){ cout<<0; } int n=0; while(z!=0){ int yu=z%2; a[n]=yu; n++; z/=2; } for(int i=n-1;i>=0;i--){ cout<<a[i]; } if(x!=0){ cout<<"."; }else{ return 0; } for(int i=0;i<9;i++){ x=x*2; int zz=x; cout<<zz; x=x-zz; if(x==0){ return 0; } } return 0; }