素数就是大于1,只能被1和它本身整除的正整数。100以内的素数共25个:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
#include <iostream.h>
void main()
{
int n = 100;
int i = 3;
int arr[100];
arr[0] = 2;
int count = 1;
while (i < n)
{
for (int j = 0; j
if (j == count)
{
arr[count] = i;
count++;
}
i++;
}
for (int ii=0; ii<count; ii++)
{
cout<<arr[ii]<<'\t';
}
cout<<endl;
}