*1408素数回文数的个数
题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1408
1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int n,cnt=0; 5 bool iss(int x) 6 { 7 for(int i=2;i*i<=x;i++) 8 if(x%i==0)return false; 9 return true; 10 } 11 bool ishws(int y) 12 { 13 char s[21]; 14 sprintf(s,"%d",y);//sprintf()函数将数字转化为字符串 此处敲黑板,sprintf()很有用 15 int len=strlen(s); 16 for(int i=0,j=len-1;i<=len/2;i++,j--) 17 if(s[i]!=s[j])return false; 18 return true; 19 } 20 21 int main() 22 { 23 scanf("%d",&n); 24 for(int i=11;i<=n;i++) 25 if(iss(i)&&ishws(i))cnt++; 26 printf("%d",cnt); 27 28 }