//创建数组来求回文数,个人认为会更直观好理解 #include <stdio.h> #include<string.h> #include<math.h> int Isprime(long long n) { for (int i = 2; i <= (long long)sqrt(n); i++) { if (n % i == 0) { return 0; break; } } return 1; } int main() { char arr[20] = { 0 }; scanf("%s", arr); int num = strlen(arr) ; long long n = 0, m = 1; for (int i = num, k = 2; i < 2 * num - 1; i++, k += 2) { arr[i] = arr[i - k]; } for (int k = num * 2 - 2; k >= 0; k--) { //求回文数 n += (arr[k] - 48) * m; m *= 10; } if (Isprime(n)) printf("prime\n"); else printf("noprime\n"); return 0; }