#include<stdio.h>
#include<omp.h>
main()
{
int prime[1000],i,j,n;
printf("\nIn order to find prime numbers from 1 to n, enter the value of n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
prime[i]=1;
}
prime[1]=0;
for(i=2;i*i<=n;i++)
{
if(prime[i]==1)
{
/* multi-threading to remove multiples of prime number i from the list (array) */
#pragma omp parallel for
for(j=i*i;j<=n;j=j+i)
{
prime[j]=0;
}
}
}
printf("\nPrime numbers from 1 to %d are\n",n);
for(i=2;i<=n;i++)
{
if(prime[i] == 1)
{
printf("%d\t ",i);
}
}
printf("\n");
}
此程序用于打印从2到n的素数。 该计划的问题是: