Run ID:90868
提交时间:2024-09-17 18:25:32
#include<iostream> using namespace std; bool judge(int n)//判断素数 { for (int i = 2;i <= n - 1;i++) if (n % i == 0)return false; return true; } int Opp(int m) //求逆序数opp { int opp=0; while (m) { opp = opp * 10 + m% 10; m /= 10;} return opp; } void prim(int m, int n) { int q=0;//q记录已输出的个数 for (;m <= n;m++) { if(judge(m)&&judge(Opp(m))) { cout << m << " ";q++; if (q % 10 == 0) cout << endl; //每输出十个数换行 } } } int main() { int m, n; cin >> m >> n; prim(m, n); return 0; }