Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
157891 袁昊贝 二进制数问题 C++ Compile Error 0 MS 0 KB 625 2026-08-18 18:12:10

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int A=0,B=0; for (int i=1;i<=1000;i++){ int num=i; string s=""; while (num>0){ s=s+char(num%a+'0'); num/=2; } reverse(s.begin(),s.end()); int s0=0,s1=0; for (int j=0;j<s.length();j++){ if (s[j]=='0'){ s0++; } else{ s1++; } } if (s1>s0){ A++; } else{ B++; } } int<<A<<" "<<B<<endl; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:9:27: error: 'a' was not declared in this scope
              s=s+char(num%a+'0');
                           ^
Main.cc:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0;j