写函数判断素数
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int judge(int n)
{
int j = 0;
for (j = 2; j <=sqrt(n); j++)
{
if (n%j == 0)
return 0;
}
return 1;
}
int main()
{
int count = 0;
int i = 0;
for (i = 100; i <= 200; i++)
{
if (judge(i) == 1)
{
printf("%d ", i);
count++;
}
}
printf("一共有%d个素数\n", count);
return 0;
}