#include <stdio.h>
int is_prime(int a){
for (int i=2;i<a;i++){
if (a%i==0){return 0;}
}
return 1;
}
int main(){
int n;
int count=10;
if (scanf("%d",&n)!=EOF && n>50 && n<20000){
// 计算150,分配给5,2,1,总数得是100
while (count>0){
n--;
if (is_prime(n)){count--;printf("%6d",n);}
}
}
else{
printf("input wrong");
}
return 0;
}
代码来自:https://yunjinqi.top/article/240