题解 | KiKi求质数个数

KiKi求质数个数

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

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

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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