Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
2369 孙浚轩 二进制数问题 C++ Compile Error 0 MS 0 KB 557 2023-12-24 00:05:09

Tests(0/0):


Code:

#include<iostream> #include<cmath> using namespace std; char intbinab(double x){ double i=pow(2,9.0),a=0,b=0; while(i>=1){ if(x/i>=1){ x-=i; a++; } else{ if(a>=1) b++; } i/=2; } if(a>b) return 'a'; else return 'b'; } int main(){ int a=0,b=0; for(double i=1;;i<=1000;i++){ if(intbinab(i)=='a') a++; else b++; } cout<<a<<" "<<b; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:24:22: warning: for increment expression has no effect [-Wunused-value]
     for(double i=1;;i<=1000;i++){
                      ^
Main.cc:24:28: error: expected ')' before ';' token
     for(double i=1;;i<=1000;i++){
                            ^
Main.cc:24:29: error: 'i' was not declared in this scope
     for(double i=1;;i<=1000;i++){
                             ^
Main.cc:24:32: error: expected ';' before ')' token
     for(double i=1;;i<=1000;i++){
                                ^