卫生么输出0??0_0?
查看原帖
卫生么输出0??0_0?
1398547
Song_Mu_yun楼主2024/9/17 14:59
#include<bits/stdc++.h>
using namespace std;

bool susu(int h)//判断素数
{
	for(int i=1;i<=sqrt(h)/*从1——n判断*/;i++)
	{
		if(h<2)
		{
			return false;	
		}
		if(h%i==0)
		{
			return false;
		}
	}
	return true;
}

bool hehe(int h)//判断回文数
{
	int t=h,n=0;
	while(t)
	{
		n=n*10+t%10;
		t/=10;
	}
	if(n==h)
	{
		return true;
	}
}

int main()
{
	int h,m=0;
	cin>>h;
	for(int i=11;i<=h;i++)
	{
		if(susu(i)&&hehe(i))
		{
			m++;
		}
	}
	cout<<m<<'\n';
	return 0;
}
2024/9/17 14:59
加载中...