Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
99933 | 任斌 | 十进制小数转二进制 | C++ | Wrong Answer | 1 MS | 268 KB | 352 | 2024-12-01 11:13:28 |
#include<bits/stdc++.h> using namespace std; int main() { double n,b; cin>>n; int a; int x[33]; int i=0,p=1; a=(int)n; b=n-a; while(a!=0){ x[i]=a%2; a/=2; i++; } for(int j=i-1;j>=0;j--){ cout<<x[j]; } if(b!=0){ cout<<"."; while(b!=0){ b*=2; cout<<(int)b; b-=(int)b; } } return 0; }
------Input------
0
------Answer-----
0
------Your output-----