Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
75391 何嘉乐 十进制小数转二进制 C++ Compile Error 0 MS 0 KB 597 2024-05-26 17:23:57

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ double m; cin>>n; int z=n;//整数 double x=n-z//小数 int b[32],cnt=0; while(z!=0){ int c=a%2; b[cnt]=c; cnt++; z=z/2; } if(cnt==0){ cout<<0; } else{ for(int i=cnt-1;i>=0;i--){ cout<<b[i]; }} if(x!=0){ cout<<"."; } else{ return 0; } for(int i=0;i<;i++){ x=x*2; int xz=x; cout<<xz; x=x-xz; x=x-xz; if(x==0){ breaj; } } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:5:7: error: 'n' was not declared in this scope
  cin>>n;
       ^
Main.cc:13:9: error: 'a' was not declared in this scope
   int c=a%2;
         ^
Main.cc:14:3: error: 'b' was not declared in this scope
   b[cnt]=c;
   ^
Main.cc:14:5: error: 'cnt' was not declared in this scope
   b[cnt]=c;
     ^
Main.cc:19:5: error: 'cnt' was not declared in this scope
  if(cnt==0){
     ^
Main.cc:26:9: error: 'b' was not declared in this scope
   cout<