22分求救
查看原帖
22分求救
1351837
SaMyse楼主2024/5/24 16:05
#include<bits/stdc++.h>
using namespace std;
bool hws(int x)
{
	int a[10]={0},i=0;
	while(x>0)
	{
		a[i]=x%10;
		x=x/10;
		i++;//判断数字总共多少位
	}
	for(int j=0;j<i;j++)
	{
		if(a[j]!=a[i-j-1])
			return false;
		else
			return true;
	}
}

bool pdzs(int x)
{
	if(x==1)
		return false;
	else
	{
		for(int i=2;i<=sqrt(x);i++)
		{
			if(x%i==0)
				return false;
		}
		return true;
	}
}
int main()
{
	long long a,b;
	cin>>a>>b;
	for(a=a;a<=b;a++)
	{
		if(hws(a))
		{
			if(pdzs(a))
				cout<<a<<endl;
		}
	}
	return 0;
}
2024/5/24 16:05
加载中...