解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int[] arr = new int[a]; //判断这个数是不是素数 int t = 0; for (int i = 11; i < a; i++) { if (tm(i)) { arr[t] = i; t++; } } //判断是不是回文 int j = 0; for(int i = 0; i < t; i++) { if(tmm(arr[i])){ j++; } } System.out.println(j); } public static boolean tm(int x) { int b = 1; for(int i = 2; i < x; i++ ) { if(x % i == 0){ b = 0; break; } } if(b != 0) { return true; }else{ return false; } } public static boolean tmm(int x) { int b = 1; int t = x; int sum = 0; while(x != 0) { b = x % 10; x = x / 10; sum = sum * 10 + b; } if(sum == t) { return true; }else{ return false; } } }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:646 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:601 |
【绝对值排序】 (C语言代码)浏览:717 |
母牛的故事 (C语言代码)浏览:934 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:549 |
【计算球体积】 (C语言代码)浏览:1104 |
最小公倍数 (C语言代码)浏览:1029 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:1466 |
蚂蚁感冒 (C语言代码)浏览:775 |
C二级辅导-等差数列 (C语言代码)浏览:695 |