如何使用C++代码实现1-100之间的素数

#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!
"; 
int i;
int j=0;
for (i = 2; j <= 100; i++) {
for (j = 2; j <= i; j++) {
if (i%j == 0) {
break;
}
}
if (j >= i) {
cout << i;
//cout << "
";
}
cout << "
";
}

}

原文地址:https://www.cnblogs.com/zgl19991001/p/11309177.html