Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
2964 | 邓小龙 | 素数检测 | C++ | Compile Error | 0 MS | 0 KB | 350 | 2024-03-15 10:29:13 |
# include<iostream> using namespace std; const int maxn=3e6; bool isprime(int x){//判断x是否为素数 for(int i=2;i<=n/i;i++){ if(x%i==0) return 0;//存在因数,0代表不是素数 } return 1;//1代表是素数 } int main(){ for(int i=1;i<=maxn;i++){ if(isprime)cout<<i<<" "; } return 0; }
Main.cc: In function 'bool isprime(int)': Main.cc:5:20: error: 'n' was not declared in this scope for(int i=2;i<=n/i;i++){ ^ Main.cc: In function 'int main()': Main.cc:12:19: warning: the address of 'bool isprime(int)' will always evaluate as 'true' [-Waddress] if(isprime)cout<<i<<" "; ^