View Code of Problem 92

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
const int maxn=10010;
int prime[maxn];
bool p[maxn];
int pNum;
void Find_Prime()
{
	for(int i=2;i<maxn;i++)
	{
		if(p[i]==false)
		{
			prime[pNum++]=i;
			for(int j=i+i;j<maxn;j+=i)
			{
				p[j]=true;
			}
		}
	}
}

int isHuiWen(int n)
{
	int s=0;
	int t=n;
	while(t/10)
	{
		s=s*10+t%10;
	    t/=10;
	}
	s=s*10+t%10;
	if(s==n)
		return 1;
	else 
		return 0;
}

int main()
{

	Find_Prime();
	p[0]=false;
	p[1]=false;
	int a,b;
	int count=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(p[i]==false&&isHuiWen(i))
		{
			count++;
			printf("%6d",i);
			if(count%5==0)printf("\n");
		}
	}
	//system("pause");


}

Double click to view unformatted code.


Back to problem 92