先定义整型变量n,输入n,通过判断函数判断,最后输出。例如://参考代码如下:#include "iostream"#include "stdio.h" using namespace std; int fun(int n){//判断函数,是质数返回1,否则返回0 int ans =1;for(int i=2;i>n;//输入n if(fun(n))//判断输出 cout>n;//输入n if(fun(n))//判断输出 cout//此为数学函数库。程序中要用到数学函数时必须包含此语句。voidf(intn)//此函数只判断是否为素数。{inti,j=0;for(i=2;i>n;f(n);return0;}