仔细。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10005;
int pnum = 0;
int prime[maxn];
bool mark[maxn] = {0};
void find_prime(){
for(int i=2;i<maxn;i++){
if(mark[i]==true) continue;
prime[pnum++] = i;
for(int j=i*i;j<maxn;j+=i){
mark[j] = true;
}
}
}
int main(){
find_prime();
int n,size,cnt;
while(scanf("%d",&n)!=EOF){
size = 0;
cnt = 0;
while(prime[size]<n){
if(prime[size]%10==1){
if(cnt==0) {
printf("%d",prime[size]);
cnt++;
}
else printf(" %d",prime[size]);
}
size++;
}
printf("\n");
}
}