须慢慢消化
int isPrime(int x,int konwnPrimes[],int numberofknownPrimes);
int main()
{
const int number = 10;
int prime[number] = {2,};
int count = 1;
int i = 3;
while(count<number)
{
if(isPrime(i,prime,count))
{
prime[count++] = i;
}
i++;
}
for(i=0;i<number;i++)
{
printf("%d",prime[i]);
if((i+1)%5) printf("\t");
else printf("\n");
}
return 0;
}
int isPrime(int x,int knownPrimes[],int numberofPrimes)
{
int ret = 1;
int i;
for(i=0;i<numberofPrimes;i++)
{
if(x%knownPrimes[i]==0)
{
ret = 0;
break;
}
}
return ret;
}