题外话
2023NOC真题卷-CSDN博客https://blog.csdn.net/2301_79396857/article/details/135909632【c++入门】图像相似度?-CSDN博客https://blog.csdn.net/2301_79396857/article/details/135900782【C++】快捷键大全-CSDN博客https://blog.csdn.net/2301_79396857/article/details/135880923【C++】实用数学无聊小程序-CSDN博客https://blog.csdn.net/2301_79396857/article/details/135880547?spm=1001.2014.3001.5501模拟帝国类游戏(c++语言)(保证能运行)-CSDN博客https://blog.csdn.net/2301_79396857/article/details/134742492?spm=1001.2014.3001.5501
说明
如果一个数从左边读和右边读都是同一个数,就称为回文数,例如686就是一个回文数。编程求10到1000内所有的既是回文数同时又是素数的自然数。
输入格式
无
输出格式
若干个数 每行一个
题解
点个赞,在拿走!!!
#include <bits/stdc++.h>
using namespace std;
bool sushu(int a){
int num=1;
for (int u=2;u<a;u++)
if (a%u==0)
num=0;
if (num)
return true;
else
return false;
}
int fan(int x){
int t=0;
while (x!=0)
{
t=t*10+x%10;
x/=10;
}
return t;
}
bool huiwen(int a){
if (a==fan(a))
return true;
else
return false;
}
int main()
{
for (int u=10;u<=1000;u++)
if (sushu(u)&&huiwen(u))
cout<<u<<endl;
return 0;
}