我给你个用C语言编写的,在vC上也能通过。#include
#include
{
int a[101];
int i, j;
for(i = 1; i < 101; i++)
a[i] = 1;
for (i = 2; i < 101; i++)
{
if(a[i]!=0)
for (j = i+1; j< 101;)
{
if(j%i==0)
a[j] = 0;
j = j+1;
}
}
for(i = 3; i < 101; i++)
if (a[i]!=0)
cout << i << " ";
return 0;
}在VC2005下调试通过