View Code of Problem 92

#include<stdio.h>
#include<math.h>
int sushu(int n){
	int i;
	for(i=2;i<n;i++)
       if(n%i==0)
	   {
		   return 0;
		   break;
	   }
	   return n;
}
int hui(int m){
	int i=1,c,ne;
	c=m;
	ne=0;
	while(c)
	{
		ne=ne*10+c%10;
		c=c/10;
	}
	if(ne==m)
			return m;
	else
		    return 0;
}
int main(){
	int f[10000];
	int i,a,b,d,t;
    scanf("%d%d",&a,&b);
	if(a>b)
	{
		t=a; a=b; b=t;
	}
	for (d=0,i=a;i<=b;i++)
	{
		if(hui(i) && sushu(i))
			f[d++]=i;
	}
	for(i=0;i<d;i++)
	{
		if((i+1)%5==0)
			printf("%6d\n",f[i]);
		else
			printf("%6d",f[i]);
	}	
	return 0;	
}

Double click to view unformatted code.


Back to problem 92