求N以内的偶数n,k=a+b,a^2+b^2=回文数,且a、b为质数
问题是为何这代码运行不起来?
测试输入
100
测试输出
2 2 8
11 11 242
17 23 818
#include<stdio.h>
int zhishu(int z) {
for (int ix = 2; ix <= 1000; ix = ix + 1) {
int pe = z / ix;
if (z == pe * ix && ix == z) {
return z;
}
else
return 0;
}
}
int huiwenshu(int h) {
int count=10;
int huiwen = 0;
int jishu = 0;
int zhongjian2;
int zhongjian;
int zhongjian3;
int result = 0;
int x1;
zhongjian2 = h;
do {
jishu = jishu + 1;
zhongjian2 = zhongjian2 / 10;
} while (zhongjian2 != 0);
do {
zhongjian = h / count;
x1 = h - zhongjian * count;
h = h - x1;
x1 = x1 / (count/10);
count = count * 10;
for (int pi = 1; pi < jishu; pi++) {
x1 = x1 * 10;
}
jishu = jishu - 1;
result = result + x1;
} while (zhongjian >= 10);
if (result == h)
return h;
else
return 0;
}
int main() {
int n, m, a, b, c, x, shu;
int zhongjian4;
scanf("%d", &n);
for (shu = 0; shu <= n; shu = shu + 2) {
for (int i = 2; i <= n; i = i + 1){
for (int t = 2; t <= n; t = t + 1) {
a = zhishu(i);
b = zhishu(t);
if (a != 0 && b != 0 && shu == (a + b)) {
c = huiwenshu(a*a + b * b);
if (c != 0)
printf("%d %d %d\n", a, b, c);
}
}
}
}
}