zhaoanqiEtayo @ 2023-11-19 19:17:09
#include<iostream>
#include<cmath>
using namespace std;
bool is1(int a)
{
int flag = 0;
for (int i = 2; i <= sqrt(a); i++)
{
if (a%i==0)
{
flag = 1;
break;
}
}
if (flag == 0)
{
return true;
}
}
bool is2(int a)
{
int j, m;
j = a;
m = 0;
while (j>0)
{
m = m * 10 + j % 10;
j /= 10;
}
if (m==a)
{
return true;
}
}
int main()
{
int i;
cin >> i;
int a, b;
cin >> a >> b;
for (int i = a; i <= b; i++)
{
if (is2(i) && is1(i))
{
cout << i << endl;
}
}
return 0;
}
by Azzero @ 2023-12-02 11:56:27
你main函数刚开始写个cin I;表达什么呢 程序没什么问题,也很快。
int i;
cin >> i;
int a, b;
cin >> a >> b;