从哪儿可以下载“回文素数”的C++软件编程

来源:百度知道 编辑:UC知道 时间:2024/05/15 19:23:23

#include<stdio.h>
#include<math.h>
void pri(void); /*驱动程序*/
int isprime(long a); /*判断a是否是素数*/
int ispalindrome(long a); /*判断a是否是回文数*/

int main()
{
pri();
return 0;
}

void pri() /*驱动程序*/
{
long i;
int j=0;
for(i=10001;i<1000000;i++)
if(isprime(i)&&ispalindrome(i))
{
printf("%10d",i);
j++;
if(j%5==0) //每行输出五个就换行
putchar('\n');
}
printf("\nThe count is %d\n",j);
}

int isprime(long a) /*判断a是否是素数*/
{
long i;
for(i=2;i<=sqrt(a);i++)
if(a%i==0)
return 0;
return 1;
}

int ispalindrome(long a) /*判断a是否是回文数*/
{
int i=