diff --git a/1567_numofsamesushu/Readme.md b/1567_numofsamesushu/Readme.md new file mode 100644 index 0000000..41f736b --- /dev/null +++ b/1567_numofsamesushu/Readme.md @@ -0,0 +1,20 @@ +# 回文素数的个数 + +[问题描述] + +教学案例,必须使用函数完成求解! + +  如果一个数从左边读和从右边读都是同一个数,就称为回文数。例如6886就是一个回文数,从给出的数据中统计出既是回文数又是素数的数的个数。 + +[输入格式] +  若干行,每行有若干个整数(待检测所有整数总个数 <= 10^5 , 0 < 每个整数的值 < 10^9 )。 + +[输出格式] +  一个整数,即回文素数的个数。 + +[输入样例] +7 12 10 11 121 1331 10301 + +[输出样例] +3 + diff --git a/1567_numofsamesushu/doc/Readme.md b/1567_numofsamesushu/doc/Readme.md new file mode 100644 index 0000000..b4f8d75 --- /dev/null +++ b/1567_numofsamesushu/doc/Readme.md @@ -0,0 +1,3 @@ +# 标题 + +* 内容 \ No newline at end of file diff --git a/1567_numofsamesushu/main.cpp b/1567_numofsamesushu/main.cpp new file mode 100644 index 0000000..f39ad54 --- /dev/null +++ b/1567_numofsamesushu/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + std::cout << "Hello Easy C++ project!" << std::endl; +} diff --git a/1567_numofsamesushu/main.exe b/1567_numofsamesushu/main.exe new file mode 100644 index 0000000..fc4df42 Binary files /dev/null and b/1567_numofsamesushu/main.exe differ diff --git a/1567_numofsamesushu/numofsamesushu.cpp b/1567_numofsamesushu/numofsamesushu.cpp new file mode 100644 index 0000000..ee353d1 --- /dev/null +++ b/1567_numofsamesushu/numofsamesushu.cpp @@ -0,0 +1,39 @@ +#include +#include +using namespace std; +int sushu(int n) +{ + if(n==1){ + return 0; + } + for (int i = 2; i * i <= n; i++) { + if (n % i == 0) { + return 0; + } + } + return 1; +} +int huiwen(string n) +{ + int len = n.size() - 1; + for (int i = 0; i <= len / 2; i++) { + if (n[i] != n[len - i]) { + return 0; + } + } + int s = 0; + for (int i = n.size() - 1; i >= 0; i--) { + s *= 10; + s += n[i]-'0'; + } + return sushu(s); +} +int main() +{ + int ans = 0; + string n; + while (cin >> n) { + ans += huiwen(n); + } + cout<