int countPrimes(int n) {
if(n<=0)return 0;
int c=0;
for(int i=2;i<n;i++){
int flag=0;
for(int j=2;j<=std::sqrt(i);j++){
if(i%j==0){
flag=1;
break;
}
}
if(flag==0)
c++;
}
return c;
}
leetcode 204:计数质数
猜你喜欢
转载自blog.csdn.net/u013263891/article/details/83035663
今日推荐
周排行