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

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; } //做对的题目: //1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1012 1020 1021 1024 1025 //1028 1039 1040 1041 1042 1043 1044 1045 1046 1047 1049 1057 1059 1065 1066 1107 //1111 1118 1120 1131 1132 1133 1135 1142 1147 1160 1164 1176 1177 1178 1181 1182 //2016 2017 2018 2019 2020 2021 2022 2023 2038 2043 2046 2047 2051 2052 2053 2054 //2055 2056 2057 2058 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2072


Run Info:

Runtime Error:Segmentation fault