后续慢慢整理
#include <iostream>
#include <cmath>
using namespace std;
bool prime(int x)
{
int y;
for (y = 2; y <= sqrt(x); y++) //当x=3,判断条件不满足,不执行for内部语句,跳转到return true
if (x%y == 0)
return false;
return true;
}
int main()
{
int n, i;
//cin >> n;
n = 100;
if (n >= 2)
cout << "2 ";
for (i = 3; i <= n; i++)
if (prime(i))
cout << i << " ";
while (1);
}