#include <iostream> using namespace std; void GetPrimenumber() { printf("求小于正整数n的素数,请输入正整数:"); int n; cin >> n; int c = 0; cout << endl; for (int t = 1; t <= n; t = t + 2) { for(int b = 1 ; b <= t ; b = b+2) { if (t % b == 0) c++; } if (c <= 2) { if(t == 1) cout<< t+1 <<'\t'; else cout << t << '\t'; } c = 0; } } int main() { GetPrimenumber(); return 0; }