View Code of Problem 92

#include <stdio.h>
#include <math.h>
int main()
{
    int m,n;
	int x,y;
	int i,j,k=0,flag,a[1000];
	scanf("%d %d",&m,&n);
	for(i=m;i<=n;i++)
	{
		x=i;
		y=0;
		while(x>0)//判断回文
		{
			y=y*10+x%10;
			x=x/10;
		}
		if(y==i)
		{
			flag=1;//为素数
			for(j=2;j<=sqrt(i);j++)
			{
				if(i%j==0)
				{
					flag=0;
				}
			}
			if(flag==1)
			{
				a[k]=i;
				printf("%6d",a[k]);
				k++;
				if(k%5==0 && k!=0)
				{
					printf("\n");
				}
			}
		}		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 92