打印100到200的素数

#include<stdio.h>
#include<math.h>
int main()
{
    int i, j,t;
    for (i = 101; i <= 200; i+=2)
    {
        t = sqrt(i);
        for (j = 2; j <= t; j++)
        {
            if (i%j == 0)
            {
                break;
            }

        }
        if (j>t)
        {
            printf("%d ", i);
        }
    }
    system("pause");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_40853073/article/details/79988384