#include
#include

void main(void)
{
 int a[101],i,j;
 
 a[1]=0;
 for(i=2; i<=100; i++)
 {
  a[i]=i;   //假设2到100都为素数
 }

 for(i=2; i<=sqrt(100); i++)
 {
  if(a[i]!=0)
  {
   for(j=i+1; j<=100; j++)
   {
    if(a[j]!=0 && a[j]%a[i]==0)
    {
     a[j]=0;
    }
    else
     NULL;
   }
  }
 }

 for(i=2; i<=100; i++)
 {
  if(a[i]!=0)
  {
   printf("%d是素数。/t",a[i]);
  }
 }
}

相关文章:

  • 2022-01-20
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案