Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
62911 曾浩然 十进制小数转二进制 C++ Runtime Error 1 MS 268 KB 1170 2023-12-30 15:34:28

Tests(0/10):


Code:

#include<bits/stdc++.h> #include<bits/stdc++.h> using namespace std; int main() { double n; cin>>n; if(n==0){ cout<<0; return 0; } int z=n; if(z==0){ cout<<0; return 0; } double x=n-z; int len; int yu[32]; while(z!=0){ yu[len++]=z%2; z/=2; } for(int i=len-1;i>=0;i--){ cout<<yu[i]; } if(x==0){ return 0; }else{ cout<<"."; } for(int i=0;i<9;i++){ x*=2; int xz=x; cout<<xz; x-=xz; if(x==0){ break; } } return 0; }


Run Info:

Runtime Error:Segmentation fault