#include "Stdio.h"
#include "Math.h"
main()
{
int a[100],i,j,n=0;
for (i=1;i<=100;i++)
{
for (j=2;j<sqrt(i);j++)
{
if ( i%j ==0 ) break;
}
if (j>=sqrt(i)+1 )
{
a[n]=i;
printf("%d is a prime number\n",a[n]); // 输出素数
n++ ;
}
}
printf ("there is %d primes",n); //输出共有共有多少个素数
getch();
}
运行结果是1 is a prime number
就这一个
[此贴子已经被作者于2007-1-28 20:04:44编辑过]