#include <iostream> #include <cmath> // for sqrt() using namespace std; #define MAX 100 //质数 int main() { cout << "2"; int i; int j; for (i = 3; i < MAX + 1; i += 2) { for ( j = 3; j <= sqrt(i); j += 2) { if (i % j == 0) { break; } } if (j > sqrt(i)) { cout << i << ‘ ‘; } } cout << endl; system("pause"); return 0; }
原文地址:https://www.cnblogs.com/jingchu/p/10053656.html
时间: 2024-10-15 05:02:06