| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 69669 | 许铭锐 | 十进制小数转二进制 | C++ | Compile Error | 0 MS | 0 KB | 422 | 2024-04-06 11:57:13 |
#include<bits/stdc++.h> using namespace std; int b; int main(){ int a[32]={0}; double n; cin>>n; int z=n; if(n==0){ cout<<0; } double x=n-z; while(z!=0){ a[cnt++]=z%2; z/=2; } for(int i=cnt-1;i>=0;i--){ cout<<a[i]; } if(x==0){ return 0; }else{ cout<<"."; } for(int i=1;i<=9;i++){ x=x*2; cout<<(int)x; x-=(int)x; if(x==0){ break; } } return 0; }
Main.cc: In function 'int main()':
Main.cc:14:5: error: 'cnt' was not declared in this scope
a[cnt++]=z%2;
^
Main.cc:17:12: error: 'cnt' was not declared in this scope
for(int i=cnt-1;i>=0;i--){
^