题解 | #KiKi求质数个数#

KiKi求质数个数

https://www.nowcoder.com/practice/d3a404ee0f8d41f98bf4707035d91086

#include <stdio.h>
#include <math.h>
int main() {
    int count = 0;
    for(int i=100;i<1000;i++)
    {
        int flag=1;//标志不是质数
        for(int j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
              flag=0;   
        }
          if(flag)
              count++;
    }
    printf("%d",count);
    return 0;
}

全部评论

相关推荐

后端转测开第一人:wlb不好吗 非得卷
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务