实验四4

# include <stdio.h>
# include <math.h> 
int main(int argc, char* argv[])
{
    int i,j,k,n;
    int a[100];
    n=sqrt(100);
    for(j=2;j<=n;j++)
    {
        if(a[j]!=1)
        {
            for(k=2;k<=100/j;k++)
            {
                a[k*j]=1;
                
            }
            
        }
        
        
    }
    for(k=2;k<=100;k++)
    {
        if(a[k]!=1)
        printf("%d\n",k);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/P201821440046/p/10895808.html