80分第一个没过,求助大佬

P5736 【深基7.例2】质数筛

@[hellowcworld](/user/798884) $n = 1$ 也不是质数
by liangbowen @ 2022-12-01 20:56:21


@[hellowcworld](/user/798884) 改成这样就过了 ```cpp #include<iostream> #include<cmath> bool isprime(unsigned int n); using namespace std; int main() { int n; cin>>n; unsigned int number[n]; for(int index=0;index<n;index++) cin>>number[index]; for(int index=0;index<n;index++) {if(isprime(number[index])) cout<<number[index]<<" ";} return 0; } bool isprime(unsigned int n) { bool jud=true; if(n==0||n==1) //更改了这里 jud=false; else for(int i=2;i<=sqrt(n);i++) { if(n%i==0) jud=false; } return jud; } ```
by liangbowen @ 2022-12-01 20:57:26


@[liangbowen](/user/367488) 感谢感谢
by hellowcworld @ 2022-12-01 21:48:17


n=0也不行
by liyuncheng @ 2023-01-25 14:29:24


|