打印质数表
include<stdio.h>
main()
{int n,i,j,tag;
scanf("%d",&n);
for(i=2;i<=n;i++)
{if(i==2||i==3)
{printf("%d ",i);}
else
{tag=0;
for(j=2;j<i;j++)
{if(i%j==0)
{tag++;
break;}}
if(tag==0)
{printf("%d ",i);}}}}
main()
{int n,i,j,tag;
scanf("%d",&n);
for(i=2;i<=n;i++)
{if(i==2||i==3)
{printf("%d ",i);}
else
{tag=0;
for(j=2;j<i;j++)
{if(i%j==0)
{tag++;
break;}}
if(tag==0)
{printf("%d ",i);}}}}
相关推荐