Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
108222 石晋骁 十进制小数转二进制 C++ Compile Error 0 MS 0 KB 493 2025-01-19 15:39:40

Tests(0/0):


Code:

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


Run Info:

Main.cc: In function 'int main()':
Main.cc:16:5: error: 'cum' was not declared in this scope
   y[cum] = yu;
     ^
Main.cc:20:14: error: 'cum' was not declared in this scope
  for(int i = cum-1;i >= 0;i--){
              ^
Main.cc:21:14: error: invalid types 'int[int]' for array subscript
   cout << z[i];
              ^