C语言实验——素数
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
输出100->200之间的素数的个数,以及所有的素数。
Input
无
Output
100->200之间的素数的个数,以及所有的素数。
Example Input
Example Output
21 101 103 ... 197 199
Hint
Author
ZJGSU
参考代码
#include<stdio.h>
int main()
{
int i;
int temp;
int a = 0;
for(i = 100; i <= 200; i++)
{
for(temp = 2; temp < i; temp++)
{
if(i%temp == 0)
{
break;
}
}
if(temp == i)
{
a++;
}
}
printf("%d\n",a);
for(i = 100; i <= 200; i++)
{
for(temp = 2; temp < i; temp++)
{
if(i % temp == 0)
{
break;
}
}
if(temp == i)
{
printf("%d ",i);
}
}
return 0;
}